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

k99*_*k99 32 python lxml centos5 python-2.6 python-import

我在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.
>>> 
Run Code Online (Sandbox Code Playgroud)

我想使用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
Run Code Online (Sandbox Code Playgroud)

bak*_*kal 53

我有同样的问题,我设法在安装包后安装它libxslt-devel,python-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
Run Code Online (Sandbox Code Playgroud)

但是,由于我还在此过程中安装了其他软件包,因此您可能需要仔细检查libxml2,libxml2-devel并且libxslt在进行此操作时.

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

  • 非常感谢~1 $ sudo yum install libxslt-devel 2. $ sudo easy_install lxml and it works~ (7认同)