-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python 3.12 fails to import pyquery with "ImportError: cannot import name 'etree' from 'lxml' " #255
Comments
My guess is it is a backwards compatibility issue with lxml. If so, you simply have to change the lxml version to whatever version works correctly. The python installer I use is pip. To reproduce it run 'pip install pyquery' and then try importing it in a test script. $ pip install pyquery [notice] A new release of pip is available: 23.2.1 -> 24.0 DESKTOP-T28NKOE ~/OneDrive/Documents/voterRolls |
The test install lxml==5.2.1 which il the latest. So I don't really get your point Try a script with "from lxml import etree" and I guess you'll have the same problem. Seems like this has nothing to do with pyquery |
Python 3.12 fails to import pyquery. The specific problem reported is:
ImportError: cannot import name 'etree' from 'lxml'
Here is the full error message I get when trying to run a simple test script that imports from requests_html:
$ python test.py
Traceback (most recent call last):
File "C:\Users\edcar\OneDrive\Documents\voterRolls\test.py", line 7, in
from requests_html import HTMLSession
File "C:\users\edcar\AppData\Roaming\Python\Python312\site-packages\requests_html.py", line 11, in
from pyquery import PyQuery
File "C:\python312\lib\site-packages\pyquery_init_.py", line 5, in
from .pyquery import PyQuery # NOQA
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\python312\lib\site-packages\pyquery\pyquery.py", line 12, in
from lxml import etree
ImportError: cannot import name 'etree' from 'lxml' (C:\python312\lib\site-packages\lxml_init_.py)
The text was updated successfully, but these errors were encountered: