1

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:

  1. included lxml to requirements.txt and it failed.

  2. I accessed AWS instance n tried to install it directly and it failed.

  3. 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.

abdullah
  • 145
  • 1
  • 1
  • 8

2 Answers2

4

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.

Jordan Reiter
  • 20,467
  • 11
  • 95
  • 161
0

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
Nilesh
  • 2,407
  • 1
  • 12
  • 20