Python Forum

Full Version: Sublime text 3 and lxml
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have been trying to get lxml working on sublime text 3.
I tried all the different standard import methods, and none worked, the main being:
from lxml import etree
failing with an error of:
Error:
ImportError: cannot import name 'etree' from 'lxml'
I then found out that ST3 has its own version of lxml, which is visible here.
However, on the actual package control website, lxml does not exist, and so I can't install it on ST3.
The last comment on this GitHub thread:
Quote:Yeah, I agree. It might not be worth putting a lot of effort into updating lxml until a stable version of ST3 with Python 3.8 is out.

I am using python3.8 and ST3 so is there no lxml out then?
If so, is there any similar alternatives?
I actually don't think it's just ST3 that's doing it.

I installed IDLE 3.8.1 so I could use something that would work. I went to install lxml but couldn't because pyenv has messed up regular pip.
I ran this command instead: python -m idlelib.idle to open up the virtual 3.8.0 IDLE, and yet, trying to import the library still got the same error.
So now I am not sure whether it is a bug with lxml or a problem with the way pyenv and pip installed the libraries.
I have done some more debugging. I removed pyenv entirely so the python installs were back to how they were before.
I reinstalled pip and lxml into python 3.8.

I opened up python in the terminal:
Output:
$ python3 Python 3.8.1 (v3.8.1:1b293b6006, Dec 18 2019, 14:08:53) [Clang 6.0 (clang-600.0.57)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import lxml >>>
Importing lxml is fine there are no errors.
As soon as I try:
Output:
>>> from lxml import etree
Error:
Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: cannot import name 'etree' from 'lxml'
However, I noticed this in the error:
(//Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/lxml/__init__.py)
Why is python 3.8 trying to import a library from 3.6?

Last update - I have it fixed.

I tried installing lxml using the pip executables directly from the python directory. It was saying that lxml was already installed in python 3.6. (even though it was python 3.8 pip)

I then tried sudo pip3 install lxml which I feel like I have done before. Either way, it installed lxml yet the error didn't go away.
The last thing I tried was removing lxml from python 3.6, so it would have to look elsewhere for lxml.
Output:
>>> import lxml >>> from lxml import etree >>>

That did the trick.

I am still yet to know why python 3.8 was trying to import libraries from python 3.6.