lxml不会使用easy_install在pypy下安装

时间:2013-06-27 11:27:07

标签: lxml pypy

做的时候:

$ 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 个答案:

答案 0 :(得分:7)

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

答案 1 :(得分:4)

$yum install python-lxmlapt-get install python-lxml 这解决了我的问题

答案 2 :(得分: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

答案 3 :(得分:1)

我已通过安装的Ubuntu软件包pypy-dev处理此问题。