3

做的时候:

$ sudo pypy -m easy_install lxml

回应是:

Searching for lxml

[...snip...]

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

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

Using build configuration of libxslt 
/usr/lib/pypy/lib-python/2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
  warnings.warn(msg)
warning: no files found matching '*.txt' under directory 'src/lxml/tests'
src/lxml/lxml.etree.c:8:22: fatal error: pyconfig.h: No such file or directory
compilation terminated.
error: Setup script exited with error: command 'cc' failed with exit status 1

同时,sudo pip install lxml工作正常。

这是怎么回事?

谢谢。

4

4 回答 4

7

sudo apt-get install python-dev在 ubuntu 13.04 上为我修复了它

于 2013-09-27T00:58:06.513 回答
4

$yum install python-lxml或者apt-get install python-lxml 这解决了我的问题。

于 2013-07-28T07:27:16.773 回答
2

我已经通过安装 Ubuntu package 解决了这个问题pypy-dev

于 2014-07-25T13:05:52.000 回答
2

我曾多次遇到过这个问题。

简短的回答

Python2: $ python2.7 setup.py clean build --with-cython install
Python3: $ pip-3.3 install lxml

长答案

假设是pip install lxml,无论您使用的是 Python2 还是 Python3,它都应该适用于所有环境。

Cython需要考虑:由于相关的性能提升,您肯定会喜欢lxml编译。Cython

由于我不知道的原因,Python2 上的编译找不到 Cython。为了更准确和绝对明确地说明这个问题,下面的两个命令都不使用 Cython:

# DO NOT use these commands. I repeat: DO NOT use these commands.
$ pip-2.7 install lxml
$ easy_install-2.7 install lxml

因此,据我所知,在使用 Python2 时,您只有一种选择,那就是:从源代码编译,Luke!

# install build environment and dependencies
$ kernel_release=$( uname -r )
$ sudo apt-get install linux-headers-${kernel_release} build-essential -y
$ sudo apt-get install libxml2-dev libxslt1-dev -y

# Download from github and compile from sources
$ git clone --branch lxml-3.2.4 https://github.com/lxml/lxml
$ python2.7 setup.py clean build --with-cython install
于 2013-11-25T17:18:52.583 回答