Getting "Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?" when installing lxml through pip

I had this issue and realised that whilst I did have libxml2 installed, I didn't have the necessary development libraries required by the python package. Installing them solved the problem:

sudo apt-get install libxml2-dev libxslt1-dev
sudo pip install lxml

Install lxml from http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml for your python version. It's a precompiled WHL with required modules/dependencies.

The site lists several packages, when e.g. using Win32 Python 3.9, use lxml‑4.5.2‑cp39‑cp39‑win32.whl.

Download the file, and then install with:

pip install C:\path\to\downloaded\file\lxml‑4.5.2‑cp39‑cp39‑win32.whl

Try to use:
easy_install lxml
That works for me, win10, python 2.7.

Tags:

Python