pip install lxml报错:Compile failed: command ‘gcc’ failed with exit status 1 解决方案

linux命令 waitig 2770℃ 百度已收录 0评论

错误详情

今天在安装scrapy框架时报错缺失lxml,使用pip install lxml时又报错,报错情况如下:

cc -I/usr/include/libxml2 -c /tmp/xmlXPathInitxq4aRa.c -o tmp/xmlXPathInitxq4aRa.o
    /tmp/xmlXPathInitxq4aRa.c:1:26: error: libxml/xpath.h: No such file or directory
    *********************************************************************************
    Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
    *********************************************************************************
    error: command 'gcc' failed with exit status 1
    
    ----------------------------------------
Command "/usr/local/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-8w5qwt/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-kMkSs3-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-8w5qwt/lxml

如图所示:

image

解决方案

网上搜索了下解决方案,试了各种方案都没有成功,最终使用以下方案成功解决。方法如下:

顺序执行以下代码即可:

yum remove audit
yum install gcc
yum install libxslt-devel libxml2-devel

本文由【waitig】发表在等英博客
本文固定链接:pip install lxml报错:Compile failed: command ‘gcc’ failed with exit status 1 解决方案
欢迎关注本站官方公众号,每日都有干货分享!
等英博客官方公众号
点赞 (1)分享 (0)