问题
I used lxml module in my code to parse AWS response. Locally it works awesome, but when i deploy this to AWS elasticbean instance, it throws errors against lxml. I tried these solutions:
included lxml to requirements.txt and it failed.
I accessed AWS instance n tried to install it directly and it failed.
I put the below line in .ebextensions/02_python.config.
09_lxml: command: "wget http://lxml.de/files/lxml-3.3.4.tgz && tar -xzvf lxml-3.3.4.tgz && cd lxml-3.3.4 && /opt/python/run/venv/bin/python setup.py install"
#command: "echo 'hello'"
leader_only: true
It worked once on an instance, but on a new instance nothing is gonna work. Need your help please.
回答1:
You can create an additional file in your .ebextensions folder that installs the necessary libraries using yum. The "key" (AWS' term) you want to use is packages
:
packages:
yum:
libxml2: []
libxml2-devel: []
libxslt: []
libxslt-devel: []
This instructs the deploy script to install these packages using yum when your app is first being deployed.
It runs before the requirements.txt file is processed, so when pip is instructed to install lxml it should have the necessary libraries.
Please see AWS's Documentation on Customizing Software on Linux Servers for more information.
I believe the packages listed above are the only requirements for lxml, but read up carefully in lxml's online documentation to be certain.
回答2:
First, update debian packages using
sudo apt-get update
Install By using
sudo apt-get install python-lxml
Using apt-get install
, It installs all dependencies for lxml
. Then, you can install lxml
using pip
also.
OR
pip install lxml
来源:https://stackoverflow.com/questions/32945077/lxml-not-getting-installed-on-aws-elasticbeanstalk-instance