32

我在 CentOS 5.4 上安装了 Python 2.6.6,

[@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

4 回答 4

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-devel并且libxslt在您使用它的时候。

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

于 2011-01-10T01:38:24.697 回答
3

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

sudo yum install -y gcc ruby-devel libxml2 libxml2-devel libxslt libxslt-devel
于 2013-02-07T05:38:47.553 回答
0

这些对我有用

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

特别是python-devel

于 2016-01-28T18:04:12.923 回答
0

如果以下不起作用

sudo yum install libxslt-devel python-devel

试试这个

pip install -U pip setuptools

然后安装

pip install lxml
于 2017-03-13T07:28:27.830 回答