本文主要是介绍pip安装lxml时报错,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1、安装lxml时报错
$sudo pip install lxml
错误信息如下:
Compile failed: command ‘gcc’ failed with exit status 1
/tmp/easy_install-lk8jAw/lxml-3.6.1/temp/xmlXPathInit2tf2ts.c:1:26: 错误:libxml/xpath.h:没有那个文件或目录
Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
error: Setup script exited with error: command ‘gcc’ failed with exit status 1
2、安装libxml2
$sudo yum install libxml2
3、重新安装lxml
$sudo pip install lxml
还是提示相同的错误信息。
4、检查是否安装 libxml2-dev、 libxslt-dev
$sudo apt-get install libxslt-dev
会同时安装依赖 libxml2-dev
5、再次安装lxml
$sudo pip install lxml
安装成功。
$ sudo pip install lxml
Collecting lxml
Using cached lxml-3.6.1.tar.gz
Installing collected packages: lxml
Running setup.py install for lxml … done
Successfully installed lxml-3.6.1
这篇关于pip安装lxml时报错的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!