python - 通过 Pip 安装 PyQuery

标签 python pip pyquery

我正在尝试通过 pip 安装 PyQuery,但出现了一个我无法理解的错误。我使用的命令是:

sudo pip install pyquery

我得到以下输出:

Requirement already satisfied (use --upgrade to upgrade): pyquery in /usr/local/lib/python2.7/dist-packages
Downloading/unpacking lxml>=2.1 (from pyquery)
Running setup.py egg_info for package lxml
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
  warnings.warn(msg)
Building lxml version 3.3.0.
Building without Cython.
ERROR: /bin/sh: 1: xslt-config: not found

** make sure the development packages of libxml2 and libxslt are installed **

Using build configuration of libxslt

Downloading/unpacking cssselect (from pyquery)
Running setup.py egg_info for package cssselect

no previously-included directories found matching 'docs/_build'
Installing collected packages: lxml, cssselect
Running setup.py install for lxml
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
  warnings.warn(msg)
Building lxml version 3.3.0.
Building without Cython.
ERROR: /bin/sh: 1: xslt-config: not found

** make sure the development packages of libxml2 and libxslt are installed **

Using build configuration of libxslt
building 'lxml.etree' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/home/imageek/scripts/facebook/build/lxml/src/lxml/includes -I/usr/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-i686-2.7/src/lxml/lxml.etree.o -w
src/lxml/lxml.etree.c:16:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
Complete output from command /usr/bin/python -c "import setuptools;__file__='/home/imageek/scripts/facebook/build/lxml/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-dyUZWZ-record/install-record.txt:
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'

warnings.warn(msg)

Building lxml version 3.3.0.

Building without Cython.

ERROR: /bin/sh: 1: xslt-config: not found



** make sure the development packages of libxml2 and libxslt are installed **



Using build configuration of libxslt

running install

running build

running build_py

copying src/lxml/includes/lxml-version.h -> build/lib.linux-i686-2.7/lxml/includes

running build_ext

building 'lxml.etree' extension

gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/home/imageek/scripts/facebook/build/lxml/src/lxml/includes -I/usr/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-i686-2.7/src/lxml/lxml.etree.o -w

src/lxml/lxml.etree.c:16:20: fatal error: Python.h: No such file or directory

compilation terminated.

error: command 'gcc' failed with exit status 1

----------------------------------------
Command /usr/bin/python -c "import setuptools;__file__='/home/imageek/scripts/facebook/build/lxml/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-dyUZWZ-record/install-record.txt failed with error code 1
Storing complete log in /home/imageek/.pip/pip.log

我觉得这与依赖项有关,但是“pip”不应该自动安装依赖项吗?

最佳答案

您缺少依赖项。尝试运行:

sudo apt-get install libxml2-dev libxslt1-dev python-dev

关于python - 通过 Pip 安装 PyQuery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21489720/

相关文章:

javascript - 将js函数转换为python函数不起作用

python - 如何从句子中提取主题?

python mysql连接器多语句

python - 导入语句 : Config file Python

python - 如何使用单元测试作为可执行入口 pip 分发 python 包?

python - pip 在安装包时出现冲突错误

python - 找不到 `pip install -r requirements.txt` 安装的包

python - 如何使这个 Python 类定义代码不那么难看

python - 如何访问 PyQuery 查询中的第一项(或第 x 项)?