Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: cannot import name 'etree' on Python 3.6

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
like image 427
Amit Kumar Avatar asked Nov 21 '18 06:11

Amit Kumar


2 Answers

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.

like image 81
Michal Kresowe Avatar answered Nov 07 '22 00:11

Michal Kresowe


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

like image 2
Cheezy Avatar answered Nov 07 '22 02:11

Cheezy