1. 程式人生 > >centos5.X 32位系統上給python2.7安裝lxml

centos5.X 32位系統上給python2.7安裝lxml

採用原始碼方式安裝python2.7,程式執行時報:

執行from lxml import etree報:

python27/lib/python2.7/site-packages/lxml-3.4.1-py2.7-linux-i686.egg/lxml/etree.so: undefined symbol: __xmlStructuredErrorContext

其原因是編譯時用的libxml2版本過低,解決方案:

yum groupinstall "Development Tools"
wget http://xmlsoft.org/sources/libxml2-2.7.8-1.src.rpm
rpm -ivh libxml2-2.7.8-1.src.rpm --nomd5
rpmbuild -ba /usr/src/redhat/SPECS/libxml2.spec
cd /usr/src/redhat/RPMS/arch
yum localinstall libxml2-2.7.8-1.i386.rpm libxml2-devel-2.7.8-1.i386.rpm libxml2-python-2.7.8-1.i386.rpm --nogpgcheck
再重新安裝lxml就ok了

參考:

http://serverfault.com/questions/266927/install-libxml2-2-7-x-on-centos-5-x