2011-01-10 68 views
32

我已經在CentOS 5.4安裝了Python 2.6.6與python2.6的安裝LXML,Setup.py:在CentOS

[[email protected] 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 
+0

都安裝在機器上什麼版本的報頭的libxslt上安裝? – Mic 2011-01-10 01:23:44

回答

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

+7

非常感謝在這裏〜$ sudo yum install libxslt-devel 2. $ sudo easy_install lxml 它的工作原理〜 – znetor 2011-01-10 01:56:13

3

它解決了我的問題,爲引入nokogiri CentOS中

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

這些作品對我來說

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

尤其是python-devel

0

如果以下內容不工作

sudo yum install libxslt-devel python-devel 

試試這個

pip install -U pip setuptools 

然後

pip install lxml