我要安装Pyquery 1.2.4版本,但是当我尝试
pip install pyquery==1.2.4
我面对
Compile failed: command 'gcc' failed with exit status 1
creating tmp
cc -I/usr/include/libxml2 -c /tmp/xmlXPathInitXZJM6c.c -o tmp/xmlXPathInitXZJM6c.o
/tmp/xmlXPathInitXZJM6c.c:1:26: error: libxml/xpath.h: No such file or directory
*********************************************************************************
Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
*********************************************************************************
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-cmQUrb/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-YFpKDF-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-cmQUrb/lxml
No matching distribution found for python-pyquery
我知道它是因为我的 Python 版本 (2.6),但由于 yum 而无法将其更新到 2.7
我该如何解决这个问题?
最佳答案
您可能缺少 GCC 编译器向您吐出的 XML 依赖项,可以通过以下方式安装它们:
yum install libxslt-devel
libxml2-devel
libxml2
libxslt
安装每个开发和发布依赖项后,尝试:
pip install pyquery==1.2.4
应该成功执行。您还应该能够使用以下方法更新 Python: here 强>。 (可能取决于您的操作系统版本。)
上述方法说明:
yum install -y centos-release-SCL yum install -y python27
Okay for centos 6.4 also On apu.0xdata.loc, after this install was done
$ which python /usr/local/bin/python $ python -V Python 2.7.3 $ ls -ltr /usr/local/bin/pyth* lrwxrwxrwx 1 root root 24 Jan 30 2013 /usr/local/bin/python -> /usr/local/bin/python2.7 -rwxr-xr-x 1 root root 6162289 Sep 3 00:59 /usr/local/bin/python2.7 -rwxr-xr-x 1 root root 1624 Sep 3 01:00 /usr/local/bin/python2.7-config
So yum will use '/usr/bin/python' which is 2.6
$ /usr/bin/python -V Python 2.6.6
"python" will give you python 2.7.
"python2.7" will give you python 2.7.
"easy_install" and "easy_install-2.7" will easy install for python 2.7. While separate files, they both seem to install into /usr/local/lib/python2.7/site-packages/
关于gcc - 如何使用 pip 安装特定版本的包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34839257/