我如何在Amazon EC2 linux上安装lxml依赖项?

我试过了:

sudo yum install libxml2-dev libxslt-dev python-dev 

我得到了:

 Loaded plugins: priorities, update-motd, upgrade-helper amzn-main/latest | 2.1 kB 00:00 amzn-updates/latest | 2.3 kB 00:00 No package libxml2-dev available. No package libxslt-dev available. No package python-dev available. 

点也没有工作。

我得到了这样的包:

 git clone --branch lxml-3.2.4 https://github.com/lxml/lxml 

然后我尝试没有cython,因为sudo python setup.py install给了我RuntimeError: ERROR: Trying to build without Cython, but pre-generated 'src/lxml/lxml.etree.c' is not available

 sudo python setup.py install --without-cython 

然后我得到:

 sudo python setup.py install --without-cython Building lxml version 3.2.4. WARNING: Trying to build without Cython, but pre-generated 'src/lxml/lxml.etree.c' is not available. WARNING: Trying to build without Cython, but pre-generated 'src/lxml/lxml.objectify.c' is not available. Building without Cython. ERROR: /bin/sh: xslt-config: command not found ** make sure the development packages of libxml2 and libxslt are installed ** Using build configuration of libxslt /usr/lib64/python2.6/distutils/dist.py:266: UserWarning: Unknown distribution option: 'bugtrack_url' warnings.warn(msg) running install running bdist_egg running egg_info writing src/lxml.egg-info/PKG-INFO writing top-level names to src/lxml.egg-info/top_level.txt writing dependency_links to src/lxml.egg-info/dependency_links.txt reading manifest file 'src/lxml.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no files found matching 'lxml.etree.c' under directory 'src/lxml' warning: no files found matching 'lxml.objectify.c' under directory 'src/lxml' warning: no files found matching 'lxml.etree.h' under directory 'src/lxml' warning: no files found matching 'lxml.etree_api.h' under directory 'src/lxml' warning: no files found matching '*.txt' under directory 'src/lxml/tests' warning: no files found matching '*.html' under directory 'doc' writing manifest file 'src/lxml.egg-info/SOURCES.txt' installing library code to build/bdist.linux-x86_64/egg running install_lib running build_py copying src/lxml/includes/lxml-version.h -> build/lib.linux-x86_64-2.6/lxml/includes running build_ext building 'lxml.etree' extension gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/home/ec2-user/lxml/src/lxml/includes -I/usr/include/python2.6 -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-2.6/src/lxml/lxml.etree.o gcc: error: src/lxml/lxml.etree.c: No such file or directory gcc: fatal error: no input files compilation terminated. error: command 'gcc' failed with exit status 4 [ec2-user@ip-172-31-14-83 lxml]$ 

它真的希望我确保安装了libxml2和libxslt的开发包

如果我能做到这一点,我希望它能工作。 有任何想法吗? 谢谢! 看来人们对此有相关的问题,但大多数都在其他系统上。


更新:基于Vor的build议,我使用了-devel扩展,并且工作来安装依赖关系。

 sudo yum install libxml2-devel libxslt-devel python-devel 

不幸的是我得到这个:

 $sudo python setup.py install --without-cython Building lxml version 3.4.0. WARNING: Trying to build without Cython, but pre-generated 'src/lxml/lxml.etree.c' is not available. WARNING: Trying to build without Cython, but pre-generated 'src/lxml/lxml.objectify.c' is not available. Building without Cython. Using build configuration of libxslt 1.1.28 Building against libxml2/libxslt in the following directory: /usr/lib64 /usr/lib64/python2.6/distutils/dist.py:266: UserWarning: Unknown distribution option: 'bugtrack_url' warnings.warn(msg) running install running bdist_egg running egg_info writing requirements to src/lxml.egg-info/requires.txt writing src/lxml.egg-info/PKG-INFO writing top-level names to src/lxml.egg-info/top_level.txt writing dependency_links to src/lxml.egg-info/dependency_links.txt reading manifest file 'src/lxml.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no files found matching 'lxml.etree.c' under directory 'src/lxml' warning: no files found matching 'lxml.objectify.c' under directory 'src/lxml' warning: no files found matching 'lxml.etree.h' under directory 'src/lxml' warning: no files found matching 'lxml.etree_api.h' under directory 'src/lxml' warning: no files found matching '*.html' under directory 'doc' writing manifest file 'src/lxml.egg-info/SOURCES.txt' installing library code to build/bdist.linux-x86_64/egg running install_lib running build_py copying src/lxml/includes/lxml-version.h -> build/lib.linux-x86_64-2.6/lxml/includes running build_ext building 'lxml.etree' extension gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/libxml2 -I/home/ec2-user/lxml/src/lxml/includes -I/usr/include/python2.6 -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-2.6/src/lxml/lxml.etree.o -w gcc: error: src/lxml/lxml.etree.c: No such file or directory gcc: fatal error: no input files compilation terminated. error: command 'gcc' failed with exit status 4 

我有同样的问题。 在这行之后:

 sudo yum install libxml2-devel libxslt-devel python-devel 

我再次尝试

 sudo yum install lxml 

它的工作:)

 sudo yum install libxml2-devel libxslt-devel python-devel 

 sudo yum install gcc 

这对我有用。

在CentOS上是python-devel ,而不是python-dev 。 和其他人一样。

在这个过程中破坏了构建中间文件。 试试rm -rf / tmp / pip-build-root

以下为我工作:

sudo yum install libxml2-devel libxslt-devel python-devel

在AWS EC2实例上:

Amazon Linux AMI release 2015.09

在我的AWS机器上,我同时安装了python2.7和python3.4,而且我正在为python3.4安装lxml – 我发现我必须使用

 sudo yum install python34-devel 

EC2 t.micro上的问题是,你用尽了内存来编译lxml包。

当你运行:dmesg | 尾巴你会看到这个问题

内存不足:杀死进程9804(cc1)得分499或牺牲子女[167588.475046]杀死进程9804(cc1)total-vm:693864kB,anon-rss:521696kB,file-rss:0kB

唯一的方法是通过yum或其他包管理器来安装python-lxml包。

加上huapito的答案。 以下代码为我工作。 sudo yum install gcc libxml2-devel libxslt-devel python-devel sudo pip install lxml