src/lxml/etree_defs.h:9:31: fatal error: libxml/xmlversion.h: No such file or directory

Install libxslt-devel & libxml2-devel using

sudo apt-get install libxml2-dev libxslt1-dev

After installing follow the above one


  1. Install Cython using

    easy_install Cython

  2. After completion of cython, install libxslt-devel & libxml2-devel using

    yum install libxslt-devel libxml2-devel

This worked for me.


The selected answer is right but I just wanted to add for those who use Fedora: libxslt1 is called libxslt when using dnf. So the command is:

sudo dnf install libxml2-devel libxslt-devel

devel for dnf is the same as dev for apt-get.


The certified answer works perfectly. But just adding the installation command for alpine to install libxslt-devel & libxml2-devel

apk add --update libxml2-dev libxslt-dev

without sudo rights you can install lxml with:

STATIC_DEPS=true pip install lxml

As mentioned in the lxml documentation