I get an error when installing lxml on an Odor 17 project in MacBook M1 chip.
First of all, when installing requirements.txt, an error occurred. So I commented out some lines in the requirements.txt file.
...
#greenlet==1.1.2 ; python_version == '3.10' # (Jammy)
#greenlet==2.0.2 ; python_version > '3.10'
...
#lxml==4.8.0 ; python_version <= '3.10'
#lxml==4.9.2 ; python_version > '3.10'
...
#reportlab==3.6.8 ; python_version <= '3.10'
#reportlab==3.6.12 ; python_version > '3.10'
...
After installing all package, I try to install manually those packages.
I was able to install greenlet and reportlab packages but, not lxml package.
After a few Google searches, I found this link: https://www.odoo.com/forum/help-1/odoo-17-install-bug-attributeerror-module-lxml-html-clean-has-no-attribute-defs-249918
According this link, the problem is due to lxml version.
So I try to install lxml 4.8.0 version (pip3 install lxml==4.8.0). But I get an other error. Then I ron pip3 install lxml and lxml 5.2.1 was been installed.
When running Odoo project I PyCharm, this error occurred:
Traceback (most recent call last):
File "/Users/youstra/odoo-server/odoo-bin", line 5, in <module>
import odoo
File "/Users/youstra/odoo-server/odoo/__init__.py", line 134, in <module>
from . import modules
File "/Users/youstra/odoo-server/odoo/modules/__init__.py", line 8, in <module>
from . import db, graph, loading, migration, module, registry, neutralize
File "/Users/youstra/odoo-server/odoo/modules/graph.py", line 11, in <module>
import odoo.tools as tools
File "/Users/youstra/odoo-server/odoo/tools/__init__.py", line 24, in <module>
from .mail import *
File "/Users/youstra/odoo-server/odoo/tools/mail.py", line 19, in <module>
from lxml.html import clean
File "/Users/youstra/odoo-server/venv/lib/python3.12/site-packages/lxml/html/clean.py", line 18, in <module>
raise ImportError(
ImportError: lxml.html.clean module is now a separate project lxml_html_clean.
Install lxml[html_clean] or lxml_html_clean directly.
When I try pip3 install lxml[html_clean] command, I get on command prompt
zsh: no matches found: lxml[html_clean].
So I try to install lxml_html_clean and the installation was successfully done.
But after this installation, I tried to run Odoo project and I got this error:
Traceback (most recent call last):
File "/Users/youstra/odoo-server/odoo-bin", line 5, in <module>
import odoo
File "/Users/youstra/odoo-server/odoo/__init__.py", line 134, in <module>
from . import modules
File "/Users/youstra/odoo-server/odoo/modules/__init__.py", line 8, in <module>
from . import db, graph, loading, migration, module, registry, neutralize
File "/Users/youstra/odoo-server/odoo/modules/graph.py", line 11, in <module>
import odoo.tools as tools
File "/Users/youstra/odoo-server/odoo/tools/__init__.py", line 24, in <module>
from .mail import *
File "/Users/youstra/odoo-server/odoo/tools/mail.py", line 32, in <module>
safe_attrs = clean.defs.safe_attrs | frozenset(
^^^^^^^^^^
AttributeError: module 'lxml.html.clean' has no attribute 'defs'
I don’t know what can I do to solve this issue.
I’m a new Odoo and Python developper.
Thanks a lot of
- Python version: 3.12
- Odoo version: 17
- iOS version: Sonoma