1

I have this strange import error with lxml.etree

 [exec] Creating deb files
 [exec] Traceback (most recent call last):
 [exec]   File "../../../../filtec-bin/packages/alpacaKV_packaging/packager.py", line 20, in <module>
 [exec]     import lxml.etree as ET
 [exec] ImportError: No module named lxml.etree

this build script has worked for us for many years in our previous build but does not here. I've already installed lxml with "pip install lxml"

$:~/eclipse-workspace/filtec-src/src$ python --version
Python 2.7.18
$:~/eclipse-workspace/filtec-src/src$ pip install lxml
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: lxml in /home/james/.local/lib/python3.10/site-packages (4.9.1)
simgineer
  • 379

1 Answers1

1

I had a similar problem, and I fixed it this way on Ubuntu 20.04 with Python 3.1.8.

Go to the terminal and type these commands:

  1. cd /home/user/.local/lib/python3.8/site-packages/lxml (Change the "user" keyword according to your system.)
  2. mv etree.pyx etree.py  

You can do it manually by going to: 

/home/user/.local/lib/python3.8/site-packages/lxml 

and rename etree.pyx to etree.py.
Then try to import lxml.etree, and hopefully it will work for you.

zx485
  • 2,865