scrapy / parsel

Parsel lets you extract data from XML/HTML documents using XPath or CSS selectors
BSD 3-Clause "New" or "Revised" License
1.11k stars 137 forks source link

Import error #276

Closed proway2 closed 1 year ago

proway2 commented 1 year ago

This error is generated ImportError: cannot import name 'PseudoElement' from 'cssselect.parser' at https://github.com/scrapy/parsel/blob/master/parsel/csstranslator.py#L8 when used with cssselect < 1.2.0.

cssselect is set to be any version from 0.9 https://github.com/scrapy/parsel/blob/master/setup.py#L28

How to reproduce:

  1. Create an env and install cssselect == 1.1.0. Install the latest parsel
    pip list
    Package    Version
    ---------- -------
    cssselect  1.1.0
    jmespath   1.0.1
    lxml       4.9.2
    packaging  23.1
    parsel     1.8.1
    pip        22.0.2
    setuptools 59.6.0
    w3lib      2.1.1
  2. Run:
    python
    Python 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from cssselect.parser import Element, FunctionalPseudoElement, PseudoElement
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    ImportError: cannot import name 'PseudoElement' from 'cssselect.parser' (/home/someuser/.pyenv/versions/test/lib/python3.10/site-packages/cssselect/parser.py)
    >>>
Gallaecio commented 1 year ago

I guess we should increase the minimum required version of cssselect then.

wRAR commented 1 year ago

I think the new type is only used in typing but I don't see why we should work around this instead of just bumping the minimum version.