ImportError: cannot import name 'etree' on Python 3.6
28,586
Solution 1
Just in case anybody has similar issue.
I also encountered this problem using Python3.6.
Just by uninstalling lxml
and installing it again with pip
the issue is resolved.
Solution 2
Got this working in Lambda with python 3.6
Turns out lxml wraps c libraries that are compiled for a certain processor architecture (I think)
Use precompiled binaries for lambda here: https://github.com/JFox/aws-lambda-lxml
Related videos on Youtube
Author by
Amit Kumar
Updated on October 05, 2021Comments
-
Amit Kumar over 2 years
I am getting error while running "from lxml import tree" on python3.6
>>> import lxml >>> from lxml import etree Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: cannot import name 'etree'
The same working on python3.4, I have tried many things to troubleshoot as below but didn't success.
python -m pip uninstall lxml python -m pip install lxml==3.6.0 pip install -t /usr/local/lib/python3.6/dist-packages lxml==3.6.0
-
Ayush Gupta over 5 yearsPossible duplicate of Receiving 'ImportError: cannot import name etree' when using lxml in Python on Mac
-
Amit Kumar over 5 yearsThe same visible at python but while import it getting same error
-
-
Samantha Atkins about 4 yearsDidn't work for me. Especially not in a lambda function environment.
-
Rohit Chatterjee over 3 yearsI changed my lambda runtime from python3.8 to python3.6 and it magically worked
-
Bracken over 2 yearsI suspect the architecture was not the difference that matters hare and there is some other difference between those two interpreters' environments.
-
polendina almost 2 yearsThe system wide APT package was
python-lxml
, and the pip package was merelylxml
in my case.