Setup.py:在 CentOS 上使用 Python2.6 安装 lxml
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4642942/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Setup.py: install lxml with Python2.6 on CentOS
提问by k99
I have installed Python 2.6.6 on CentOS 5.4,
我已经在 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.
>>>
I want to use the lxml module, but build from sources failed:
我想使用 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
采纳答案by bakkal
I had the same issue, I managed to install it after installing the package libxslt-develand python-develwhich seems to be your problem:
我遇到了同样的问题,我在安装软件包后设法安装了它libxslt-devel,python-devel这似乎是您的问题:
yum install libxslt-devel python-devel
yum install libxslt-devel python-devel
python setup.py install
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
However since I also installed other packages in the process, you might want to double check libxml2, libxml2-develand libxsltwhile you are at it.
但是,由于我还在此过程中安装了其他软件包,因此您可能需要仔细检查libxml2,libxml2-devel并且libxslt在此过程中。
Here is some information on how to build lxml: http://lxml.de/build.html
以下是有关如何构建 lxml 的一些信息:http: //lxml.de/build.html
回答by bakkal
It solved my problem for nokogiri in Centos
它解决了我在 Centos 中的 nokogiri 问题
sudo yum install -y gcc ruby-devel libxml2 libxml2-devel libxslt libxslt-devel
回答by user2754799
these works for me
这些对我有用
yum -y install python-devel gcc libxml2 libxml2-devel libxslt libxslt-devel
especially the python-devel
尤其是 python-devel
回答by Sandeep G
If the below doesn't work
如果以下不起作用
sudo yum install libxslt-devel python-devel
try this
尝试这个
pip install -U pip setuptools
and then install by
然后通过安装
pip install lxml

