Lxml does not install on AWS Elasticbeanstalk instance

I used the lxml module in my code to parse the AWS response. Locally, this works amazingly, but when I use this for an AWS flexiblebean instance, it throws errors against lxml. I tried these solutions:

  • lxml is included in requirements.txt and it failed.

  • I turned to an instance of AWS n that tried to install it directly, and it failed.

  • I put the line below 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 the instance, but nothing happens on the new instance. You need your help.

+1
source share
2 answers

You can create an additional file in the .ebextensions folder, which installs the necessary libraries using yum. The term key (AWS) you want to use is packages :

 packages: yum: libxml2: [] libxml2-devel: [] libxslt: [] libxslt-devel: [] 

This instructs the deployment script to install these packages using yum when your application is first deployed.

It starts before processing the requirements.txt file, therefore, when lxml is specified to the Pp command, it must have the necessary libraries.

For more information, see the AWS documentation on Configuring Software on Linux Servers .

I believe the packages listed above are the only lxml requirements, but read the lxml online documentation carefully .

+4
source

Upgrade debian packages first using

 sudo apt-get update 

Install with

  sudo apt-get install python-lxml 

Using apt-get install , it installs all the dependencies for lxml . Then you can install lxml also with pip .

OR

 pip install lxml 
0
source

Source: https://habr.com/ru/post/1202411/


All Articles