Question

So they removed the cssselect package from lxml.. Now my python program is useless. I just can't figure out how I could get it working:

ImportError: cssselect seems not to be installed. See http://packages.python.org/cssselect/

I've tried to copy cssselect directory to my code directory -> solves the error when compiling bytecode files, but when running the program, the error persists.

I've tried to rewrite my lxml.cssselect commands but no result.

I've searched the whole internet, but without an answer.

now I just have line:

from lxml.html import parse

and the code that uses cssselect is

inner = html.xpath('//*[@id="Content..."]')
for b in inner:
...
  for a in b.cssselect('p'):
  ...

So either how to import it so the original code works? Do I need to manually copy it to some place or what?

or how to find/replace the code to get it working?

(oh and a note, ofc I've installed both lxml and cssselect packages)

Was it helpful?

Solution

The problem was with the cssselect installation. For some unidentified reason the cssselect package was installed to /root/.local/lib/python2.7/site-packages/ instead of /usr/local/lib/python2.7/dist-packages/.

Cssselect was installed with pip install cssselect on Debian GNU/Linux 7.4 (wheezy, Linux 3.2.0-4-amd64 x86_64). Don't know if it was just some weird typo of mine, or a bug.

The solution was to uninstall cssselect and reinstall it. This time it went to correct place and everything works as before. There was no need to modify python code at all.

Ty, for you answers ;)

OTHER TIPS

My solution was to install cssselect using pip3:

sudo pip3 install cssselect
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top