Skip to content

Python 3.12 fails to import pyquery with "ImportError: cannot import name 'etree' from 'lxml' " #255

Description

@edcarstens

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions