Installing lxml module in python

后端 未结 7 2102
温柔的废话
温柔的废话 2020-12-02 09:52

while running a python script, I got this error

  from lxml import etree
ImportError: No module named lxml

now I tried to install lxml

相关标签:
7条回答
  • For python 3 this worked for me

    sudo apt-get install python3-lxml
    
    0 讨论(0)
  • 2020-12-02 10:01

    If you are encountering this issue on an Alpine based image try this :

    apk add --update --no-cache g++ gcc libxml2-dev libxslt-dev python-dev libffi-dev openssl-dev make
    

    // pip install -r requirements.txt

    0 讨论(0)
  • 2020-12-02 10:06

    Just do:

    sudo apt-get install python-lxml
    

    For Python 2 (e.g., required by Inkscape):

    sudo apt-get install python2-lxml
    

    If you are planning to install from source, then albertov's answer will help. But unless there is a reason, don't, just install it from the repository.

    0 讨论(0)
  • 2020-12-02 10:08

    You need to install Python's header files (python-dev package in debian/ubuntu) to compile lxml. As well as libxml2, libxslt, libxml2-dev, and libxslt-dev:

    apt-get install python-dev libxml2 libxml2-dev libxslt-dev
    
    0 讨论(0)
  • 2020-12-02 10:15

    If you're running python3, you'll have to do:

    pip3 install lxml

    0 讨论(0)
  • 2020-12-02 10:20

    I solved it upgrading the lxml version with:

    pip install --upgrade lxml
    
    0 讨论(0)
提交回复
热议问题