lxml gcc失败,退出状态为1 ubuntu 16.04

时间:2016-11-28 10:43:59

标签: python lxml

sudo easy_install lxml
Searching for lxml
Reading https://pypi.python.org/simple/lxml/
Best match: lxml 3.6.4
Downloading https://pypi.python.org/packages/4f/3f/cf6daac551fc36cddafa1a71ed48ea5fd642e5feabd3a0d83b8c3dfd0cb4/lxml-3.6.4.tar.gz#md5=6dd7314233029d9dab0156e7b1c7830b
Processing lxml-3.6.4.tar.gz
Writing /tmp/easy_install-w86uerbh/lxml-3.6.4/setup.cfg
Running lxml-3.6.4/setup.py -q bdist_egg --dist-dir /tmp/easy_install-w86uerbh/lxml-3.6.4/egg-dist-tmp-smgpuu2j
Building lxml version 3.6.4.
Building without Cython.
Using build configuration of libxslt 1.1.28
src/lxml/lxml.etree.c:83:20: fatal error: Python.h: No such file or directory
compilation terminated.
Compile failed: command 'x86_64-linux-gnu-gcc' failed with exit status 1
/tmp/easy_install-w86uerbh/lxml-3.6.4/temp/xmlXPathInitmvs80t9r.c:2:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
 main (int argc, char **argv) {
 ^
error: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

那么如何安装lxml lib?我试过pip,但也有同样的结束。

2 个答案:

答案 0 :(得分:0)

尝试安装以下软件包:

sudo apt-get install libxml2-dev libxslt1-dev python-dev

如果这不起作用,请确保它不是内存问题,如果是这样,您将需要增加机器内存。

答案 1 :(得分:0)

只需为实例添加更多内存即可完成lxml编译