سؤال

I'm trying to install pyquery on Windows and I get the following error when I try to do selects like this d('p:first'). Everything else seems to be working. Any idea what am I missing? This issue happens only on my windows machine, on my MAC works fine.

Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyquery import PyQuery as pq
>>> d = pq("<p></p>")
>>> d('p:first')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\pyquery-1.2.4-py2.7.egg\pyquery\pyquery.py
", line 237, in __call__
    result = self.__class__(*args, parent=self, **kwargs)
  File "C:\Python27\lib\site-packages\pyquery-1.2.4-py2.7.egg\pyquery\pyquery.py
", line 213, in __init__
    xpath = self._css_to_xpath(selector)
  File "C:\Python27\lib\site-packages\pyquery-1.2.4-py2.7.egg\pyquery\pyquery.py
", line 223, in _css_to_xpath
    return self._translator.css_to_xpath(selector, prefix)
  File "build\bdist.win32\egg\cssselect\xpath.py", line 188, in css_to_xpath
  File "build\bdist.win32\egg\cssselect\xpath.py", line 188, in <genexpr>
  File "build\bdist.win32\egg\cssselect\xpath.py", line 208, in selector_to_xpat
h
  File "build\bdist.win32\egg\cssselect\xpath.py", line 230, in xpath
  File "build\bdist.win32\egg\cssselect\xpath.py", line 272, in xpath_pseudo
  File "C:\Python27\lib\site-packages\pyquery-1.2.4-py2.7.egg\pyquery\cssselectp
atch.py", line 19, in xpath_first_pseudo
    xpath.add_post_condition('position() = 1')
AttributeError: 'XPathExpr' object has no attribute 'add_post_condition'
>>>
هل كانت مفيدة؟

المحلول

I had installed pyquery with "easy_install pyquery" and this was causing this error. I removed it and then installed it from https://github.com/gawel/pyquery with python setup.py install and now it's working.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top