ImportError: cannot import name 'etree' on Python 3.6

Amit Kumar picture Amit Kumar · Nov 21, 2018 · Viewed 14.5k times · Source

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

Answer

Michal Kresowe picture Michal Kresowe · Dec 22, 2018

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.