Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sublime text 3 and lxml
#1
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?
Reply
#2
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.
Reply
#3
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  while loop not working-I am using sublime text editor mma_python 4 1,125 Feb-05-2023, 06:26 PM
Last Post: deanhystad
  Sublime Text Editor not recognizing Python elroberto 5 2,867 Jun-13-2022, 04:00 PM
Last Post: rob101
  Code folding in Sublime Text Mondata 2 2,797 Mar-12-2021, 04:16 PM
Last Post: Mondata
  How to link Sublime Text 3 Build system to Python 3.9 Using Windows 10 Fanman001 2 4,598 Mar-04-2021, 03:09 PM
Last Post: martpogs
  Sublime Text TechNitium 4 2,762 Jan-23-2021, 08:41 AM
Last Post: TechNitium
  sublime & intellisence luke83 0 1,626 Nov-20-2020, 08:26 PM
Last Post: luke83
  Sublime Text + Anaconda not indenting Python code correctly Maxximiliann 0 1,990 Jun-13-2020, 06:09 PM
Last Post: Maxximiliann
  switching from pycharm to sublime issue Drifter 2 1,988 Jun-09-2020, 09:19 PM
Last Post: Drifter
  Contextual pop-up menus in Sublime Text Mondata 4 2,431 Apr-08-2020, 06:32 PM
Last Post: buran
  Sublime Text 3 WinError 2 File Specified HelloWorld17 0 2,811 Apr-02-2020, 09:03 AM
Last Post: HelloWorld17

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020