Setup.py:在CentOS上使用Python2.6安装lxml

时间:2011-01-10 01:12:45

标签: python lxml python-2.6 python-import centos5

我在CentOS 5.4上安装了Python 2.6.6,

[siyuan.tong@SC-055 lxml-2.3beta1]$ python
Python 2.6.6 (r266:84292, Jan  4 2011, 09:49:55) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

我想使用lxml模块,但是从源代码构建失败:

src/lxml/lxml.etree.c:157929: error: ‘xsltLibxsltVersion’ undeclared (first use in this function)
src/lxml/lxml.etree.c:157941: error: ‘__pyx_v_4lxml_5etree_XSLT_DOC_DEFAULT_LOADER’ undeclared (first use in this function)
src/lxml/lxml.etree.c:157941: error: ‘xsltDocDefaultLoader’ undeclared (first use in this function)
src/lxml/lxml.etree.c:157950: error: ‘__pyx_f_4lxml_5etree__xslt_doc_loader’ undeclared (first use in this function)
error: command 'gcc' failed with exit status 1

4 个答案:

答案 0 :(得分:53)

我遇到了同样的问题,我设法在安装好的软件包libxslt-develpython-devel之后安装它,这似乎是您的问题:

yum install libxslt-devel python-devel

python setup.py install

Installed /usr/lib/python2.6/site-packages/lxml-2.2.8-py2.6-linux-i686.egg
Processing dependencies for lxml==2.2.8
Finished processing dependencies for lxml==2.2.8

但是,由于我还在此过程中安装了其他软件包,因此您可能需要仔细检查libxml2libxml2-devellibxslt

以下是有关如何构建lxml的一些信息:http://lxml.de/build.html

答案 1 :(得分:3)

它在Centos中解决了我对nokogiri的问题

sudo yum install -y gcc ruby-devel libxml2 libxml2-devel libxslt libxslt-devel

答案 2 :(得分:0)

这些对我有用

yum -y install python-devel gcc libxml2 libxml2-devel libxslt libxslt-devel

尤其是python-devel

答案 3 :(得分:0)

如果以下不起作用

sudo yum install libxslt-devel python-devel

试试这个

pip install -U pip setuptools

然后按

安装
pip install lxml