系统是CentOS5.5,Python版本是Python2.7.3,使用pip-2.7安装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
解决方法是先安装libxslt开发包:
yum install libxslt-devel
python setup.py install
然后安装lxml:
pip-2.7 install lxml
[root@dev1 scripts]# rpm -qa | grep libxml
libxml2-2.6.26-2.1.15.el5_8.5
libxml2-devel-2.6.26-2.1.15.el5_8.5
libxml2-python-2.6.26-2.1.2.8
libxml2-devel-2.6.26-2.1.15.el5_8.5
libxml2-2.6.26-2.1.15.el5_8.5
iefreer