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

时间:2023-01-26 12:46:45

I tried:

我试着:

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

and I got:

我:

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.

pip did not work either.

pip也不起作用。

I got the package like this:

我收到的包裹是这样的:

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

Then I tried without cython because sudo python setup.py install gave me RuntimeError: ERROR: Trying to build without Cython, but pre-generated 'src/lxml/lxml.etree.c' is not available

然后我尝试不使用cython,因为sudo python设置。py安装给了我运行时错误:错误:试图在没有Cython的情况下构建,但是预先生成了“src/lxml/lxml.etree”。c '是不可用的

sudo python setup.py install --without-cython

Then I got:

然后我得到了:

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]$ 

It really wants me to make sure the development packages of libxml2 and libxslt are installed.

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

If I can do that I hope it will work. Any ideas? Thanks! It seems people have related issues to this, but most are on other systems.

如果我能做到,我希望它能起作用。什么好主意吗?谢谢!似乎人们对此有相关的问题,但大多数都在其他系统上。


UPDATE: Based on Vor's suggestion I used the -devel extension and that worked to install the dependencies.

更新:基于Vor的建议,我使用了-devel扩展,并使用它来安装依赖项。

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

Unfortunately I get this:

不幸的是我得到了这个:

$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

8 个解决方案

#1


8  

I had the same problem. After this line:

我也有同样的问题。在这条线:

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

I tried again with

我再次尝试

sudo yum install lxml

And it worked :)

和它工作:)

#2


2  

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

add

添加

sudo yum install gcc

and this worked for me.

这对我很有效。

#3


1  

On CentOS it is python-devel, not python-dev. Same thing with others.

在CentOS,它是python-devel,而不是python-dev。与别人一样。

#4


0  

Broken build left intermediate files in the process. try rm -rf /tmp/pip-build-root

破碎的构建在过程中留下中间文件。rm射频/ tmp / pip-build-root试试

#5


0  

The following worked for me:

以下是我的工作经验:

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

sudo yum安装libxml2-devel libxsl -devel -devel - python-devel

On AWS EC2 instance:

在AWS EC2实例:

Amazon Linux AMI release 2015.09

Amazon Linux AMI发行版2015.09

#6


0  

On my AWS machine I had both python2.7 and python3.4 and I was looking to install lxml for python3.4 - I found that I had to use

在我的AWS机器上,我有python2.7和python3.4,我想为python3.4安装lxml——我发现我必须使用它

sudo yum install python34-devel

#7


0  

The problem on EC2 t.micro is that you run out of memory to compile the lxml package.

EC2 t上的问题。micro就是你用完内存来编译lxml包。

When you run: dmesg | tail you will see the issue

当您运行:dmesg |尾部时,您将看到问题

[167588.470868] Out of memory: Kill process 9804 (cc1) score 499 or sacrifice child [167588.475046] Killed process 9804 (cc1) total-vm:693864kB, anon-rss:521696kB, file-rss:0kB

[167588.470868]内存不足:Kill process 9804 (cc1)得分499或牺牲儿童[167588.475046]杀死进程9804 (cc1) total-vm:693864kB, anon-rss:521696kB,文件-rss:0kB。

The only way is to install the python-lxml package via yum or other package manager.

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

#8


0  

Add on to huapito's answer. Following code work for me. sudo yum install gcc libxml2-devel libxslt-devel python-devel sudo pip install lxml

再加上huapito的回答。下面的代码对我有用。sudo yum安装gcc libxml2-devel libxsl -devel -devel python-devel sudo pip安装lxml

#1


8  

I had the same problem. After this line:

我也有同样的问题。在这条线:

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

I tried again with

我再次尝试

sudo yum install lxml

And it worked :)

和它工作:)

#2


2  

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

add

添加

sudo yum install gcc

and this worked for me.

这对我很有效。

#3


1  

On CentOS it is python-devel, not python-dev. Same thing with others.

在CentOS,它是python-devel,而不是python-dev。与别人一样。

#4


0  

Broken build left intermediate files in the process. try rm -rf /tmp/pip-build-root

破碎的构建在过程中留下中间文件。rm射频/ tmp / pip-build-root试试

#5


0  

The following worked for me:

以下是我的工作经验:

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

sudo yum安装libxml2-devel libxsl -devel -devel - python-devel

On AWS EC2 instance:

在AWS EC2实例:

Amazon Linux AMI release 2015.09

Amazon Linux AMI发行版2015.09

#6


0  

On my AWS machine I had both python2.7 and python3.4 and I was looking to install lxml for python3.4 - I found that I had to use

在我的AWS机器上,我有python2.7和python3.4,我想为python3.4安装lxml——我发现我必须使用它

sudo yum install python34-devel

#7


0  

The problem on EC2 t.micro is that you run out of memory to compile the lxml package.

EC2 t上的问题。micro就是你用完内存来编译lxml包。

When you run: dmesg | tail you will see the issue

当您运行:dmesg |尾部时,您将看到问题

[167588.470868] Out of memory: Kill process 9804 (cc1) score 499 or sacrifice child [167588.475046] Killed process 9804 (cc1) total-vm:693864kB, anon-rss:521696kB, file-rss:0kB

[167588.470868]内存不足:Kill process 9804 (cc1)得分499或牺牲儿童[167588.475046]杀死进程9804 (cc1) total-vm:693864kB, anon-rss:521696kB,文件-rss:0kB。

The only way is to install the python-lxml package via yum or other package manager.

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

#8


0  

Add on to huapito's answer. Following code work for me. sudo yum install gcc libxml2-devel libxslt-devel python-devel sudo pip install lxml

再加上huapito的回答。下面的代码对我有用。sudo yum安装gcc libxml2-devel libxsl -devel -devel python-devel sudo pip安装lxml