无法在CentOS上安装lxml

时间:2014-01-02 15:24:19

标签: python centos lxml

我正在尝试安装lxml但遇到一些困难:

[root@ip-xx-xxx-xx-113 init.d]# pip install lxml
Downloading/unpacking lxml
  Running setup.py egg_info for package lxml
    /usr/lib64/python2.6/distutils/dist.py:266: UserWarning: Unknown distribution option: 'bugtrack_url'
      warnings.warn(msg)
    Building lxml version 3.3.0.beta2.
    Building without Cython.
    Using build configuration of libxslt 1.1.26
    Building against libxml2/libxslt in the following directory: /usr/lib64
    warning: no files found matching '*.py' under directory 'fake_pyrex'
Installing collected packages: lxml
  Running setup.py install for lxml
    /usr/lib64/python2.6/distutils/dist.py:266: UserWarning: Unknown distribution option: 'bugtrack_url'
      warnings.warn(msg)
    Building lxml version 3.3.0.beta2.
    Building without Cython.
    Using build configuration of libxslt 1.1.26
    Building against libxml2/libxslt in the following directory: /usr/lib64
    building 'lxml.etree' extension
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/libxml2 -I/tmp/pip-build-root/lxml/src/lxml/includes -I/usr/include/python2.6 -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-2.6/src/lxml/lxml.etree.o
    src/lxml/lxml.etree.c: In function ‘__pyx_pf_4lxml_5etree_11TreeBuilder_4data’:
    src/lxml/lxml.etree.c:102248: warning: passing argument 1 of ‘__pyx_f_4lxml_5etree_11TreeBuilder__handleSaxData’ from incompatible pointer type
    src/lxml/lxml.etree.c:101849: note: expected ‘struct __pyx_obj_4lxml_5etree_TreeBuilder *’ but argument is of type ‘struct __pyx_obj_4lxml_5etree__SaxParserTarget *’
    src/lxml/lxml.etree.c: In function ‘__pyx_pf_4lxml_5etree_11TreeBuilder_6start’:
    src/lxml/lxml.etree.c:102385: warning: passing argument 1 of ‘__pyx_f_4lxml_5etree_11TreeBuilder__handleSaxStart’ from incompatible pointer type
    src/lxml/lxml.etree.c:101549: note: expected ‘struct __pyx_obj_4lxml_5etree_TreeBuilder *’ but argument is of type ‘struct __pyx_obj_4lxml_5etree__SaxParserTarget *’
    src/lxml/lxml.etree.c: In function ‘__pyx_pf_4lxml_5etree_11TreeBuilder_8end’:
    src/lxml/lxml.etree.c:102443: warning: passing argument 1 of ‘__pyx_f_4lxml_5etree_11TreeBuilder__handleSaxEnd’ from incompatible pointer type
    src/lxml/lxml.etree.c:101773: note: expected ‘struct __pyx_obj_4lxml_5etree_TreeBuilder *’ but argument is of type ‘struct __pyx_obj_4lxml_5etree__SaxParserTarget *’
    src/lxml/lxml.etree.c: In function ‘__pyx_pf_4lxml_5etree_11TreeBuilder_10pi’:
    src/lxml/lxml.etree.c:102601: warning: passing argument 1 of ‘__pyx_f_4lxml_5etree_11TreeBuilder__handleSaxPi’ from incompatible pointer type
    src/lxml/lxml.etree.c:101889: note: expected ‘struct __pyx_obj_4lxml_5etree_TreeBuilder *’ but argument is of type ‘struct __pyx_obj_4lxml_5etree__SaxParserTarget *’
    src/lxml/lxml.etree.c: In function ‘__pyx_pf_4lxml_5etree_11TreeBuilder_12comment’:
    src/lxml/lxml.etree.c:102654: warning: passing argument 1 of ‘__pyx_f_4lxml_5etree_11TreeBuilder__handleSaxComment’ from incompatible pointer type
    src/lxml/lxml.etree.c:102015: note: expected ‘struct __pyx_obj_4lxml_5etree_TreeBuilder *’ but argument is of type ‘struct __pyx_obj_4lxml_5etree__SaxParserTarget *’
    src/lxml/lxml.etree.c: In function ‘__pyx_f_4lxml_5etree__xslt_resolve_from_python’:
    src/lxml/lxml.etree.c:137740: warning: enumeration value ‘__pyx_e_4lxml_5etree_PARSER_DATA_INVALID’ not handled in switch
    src/lxml/lxml.etree.c: In function ‘__pyx_pf_4lxml_5etree_4XSLT_18__call__’:
    src/lxml/lxml.etree.c:141814: warning: passing argument 1 of ‘__pyx_f_4lxml_5etree_12_XSLTContext__copy’ from incompatible pointer type
    src/lxml/lxml.etree.c:139749: note: expected ‘struct __pyx_obj_4lxml_5etree__XSLTContext *’ but argument is of type ‘struct __pyx_obj_4lxml_5etree__BaseContext *’
    src/lxml/lxml.etree.c: In function ‘__pyx_f_4lxml_5etree__copyXSLT’:
    src/lxml/lxml.etree.c:143212: warning: passing argument 1 of ‘__pyx_f_4lxml_5etree_12_XSLTContext__copy’ from incompatible pointer type
    src/lxml/lxml.etree.c:139749: note: expected ‘struct __pyx_obj_4lxml_5etree__XSLTContext *’ but argument is of type ‘struct __pyx_obj_4lxml_5etree__BaseContext *’
    src/lxml/lxml.etree.c: At top level:
    src/lxml/lxml.etree.c:12826: warning: ‘__pyx_f_4lxml_5etree_displayNode’ defined but not used
    src/lxml/lxml.etree.c: In function ‘__pyx_f_4lxml_5etree_11_BaseParser__parseDocFromFile’:
    src/lxml/lxml.etree.c:90304: warning: ‘__pyx_r’ may be used uninitialized in this function
    src/lxml/lxml.etree.c: In function ‘__pyx_f_4lxml_5etree_11_BaseParser__parseUnicodeDoc’:
    src/lxml/lxml.etree.c:89619: warning: ‘__pyx_r’ may be used uninitialized in this function
    src/lxml/lxml.etree.c: In function ‘__pyx_f_4lxml_5etree_11_BaseParser__parseDoc’:
    src/lxml/lxml.etree.c:89970: warning: ‘__pyx_r’ may be used uninitialized in this function
    src/lxml/lxml.etree.c: In function ‘__pyx_f_4lxml_5etree_11_BaseParser__parseDocFromFilelike’:
    src/lxml/lxml.etree.c:90623: warning: ‘__pyx_r’ may be used uninitialized in this function

所以输出只是挂起而没有安装。

以下是有关机器的一些信息:

[root@ip-xx-xxx-xx-113 ec2-user]# cat /proc/version
Linux version 2.6.32-431.el6.x86_64 (mockbuild@c6b8.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) ) #1 SMP Fri Nov 22 03:15:09 UTC 2013

[root@ip-xx-xxx-xx-113 ec2-user]# cat /etc/issue
CentOS release 6.5 (Final)
Kernel \r on an \m

[root@ip-xx-xxx-xx-113 ec2-user]# python --version
Python 2.6.6

2 个答案:

答案 0 :(得分:3)

首先安装这些依赖项

sudo yum install libxml2 libxml2-devel libxml2-python libxslt libxslt-devel

pip install lxml or easy_install lxml

建议使用virtual environment。它有助于隔离python环境。

答案 1 :(得分:2)

评论太低。我在Centos 7上安装lxml时遇到了麻烦,但在上面链接的post Jimothy中成功使用了nairobi的答案。     yum install libxslt-devel libxml2-devel

希望这可以帮助将来找到这篇文章的人。