lxml not getting installed on AWS Elasticbeanstalk instance

拥有回忆 提交于 2019-12-02 09:48:16

问题


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.


回答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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!