環境以下:python
pip install lxml
執行上面的命令,有相似下面的提示:c++
src/lxml/lxml.etree.c:188133: error: ‘xsltDocDefaultLoader’ undeclared (first use in this function) src/lxml/lxml.etree.c:188142: warning: implicit declaration of function ‘xsltSetLoaderFunc’ src/lxml/lxml.etree.c:188142: error: ‘xsltDocLoaderFunc’ undeclared (first use in this function) src/lxml/lxml.etree.c:188142: error: expected ‘)’ before ‘__pyx_f_4lxml_5etree__xslt_doc_loader’ src/lxml/lxml.etree.c:188393: warning: implicit declaration of function ‘xsltRegisterAllExtras’ src/lxml/lxml.etree.c:188402: warning: implicit declaration of function ‘exsltRegisterAll’ error: Setup script exited with error: command 'gcc' failed with exit status 1
像這種狀況,通常是對應的devel包沒有安裝,可是即便我安裝了libxml2 和libxml2-devel,仍是一樣的提示
已經確認過gcc, gcc-c++等基礎包安裝的了shell
[root@localhost]$ rpm -qa |grep gcc gcc-4.4.7-4.el6.x86_64 libgcc-4.4.7-4.el6.x86_64 gcc-c++-4.4.7-4.el6.x86_64
查看pypi上lxml的文檔 lxml 3.4.1,能夠在第一段就看到下面的一句話:this
Powerful and Pythonic XML processing library combining libxml2/libxslt with the ElementTree API.
這裏指出了lxml 會使用到 libxml2/libxslcode
yum search libxml yum search libxsl 會發現有libxslt-devel和libxml2-devel
執行shell命令:xml
yum -y install libxslt-devel
上面的命令執行以後,會自動安裝和更新以下的軟件包:ip
安裝上面了6個軟件包以後,pip install lxml
就能成功安裝lxml了ci