libxml install error using pip

Solution 1:

** make sure the development packages of libxml2 and libxslt are installed **

From the lxml documentation, assuming you are running a Debian-based distribution :

sudo apt-get install libxml2-dev libxslt-dev python-dev

For Debian based systems, it should be enough to install the known build dependencies of python-lxml or python3-lxml, e.g.

sudo apt-get build-dep python3-lxml

Solution 2:

This worked for me:

yum install libxslt-devel libxml2-devel

Solution 3:

In case, you are using Ubuntu/Lubuntu 13.04 or Ubuntu 13.10 and having problem with "/usr/bin/ld: cannot find -lz", you may need also install zlib1g-dev package:

sudo apt-get install -y zlib1g-dev

Put it all together:

sudo apt-get install -y libxml2-dev libxslt1-dev zlib1g-dev python3-pip
sudo pip3 install lxml

Solution 4:

No you are missing the Python header files. This mostly happens on Linux when you are using the system Python (there are reasons not to do that, but that's a different question).

You probably need to install some package, and it's probably called python-dev or python-devel.

 sudo yum install python-devel

or

 sudo aptitude install python-dev

Or somesuch.