Libxml Install Error Using Pip

Installing lxml, libxml2, libxslt for Python 3.5 on Windows 10

lxml uses libxml2, libxslt (in background) but libxml2, libxslt are not Python modules - it's C/C++ libraries. So you can't install them using pip. You have to download and install them manually.

You can find precompiled lxml for Windows on Unofficial Windows Binaries for Python Extension Packages

  • cp35 in file name means version for Python 3.5.
  • win32 in file name means version for 32bit Python.
  • amd64 in file name means version for 64bit Python.

You probably use 32bit Python because I see 32 and (x86) in your path

C:\program files (x86)\python35-32\python.exe

You should find links to libxml2, libxslt on this page too. This libraries has .dll and .exe files and you can put them in any folder which is in PATH variable. Libraries mostly are installed in C:\Windows or in subfolder.

libxml2, libxslt may have also C/C++ header files *.h which you may need when you compile lxml. (on Linux this files are in separated packages
libxml2-dev, libxslt-dev)


BTW: You can use Anaconda distribution (instead of Python.org distribution). It installs the same Python but with some precompiled modules - ie. it installs lxml automatically. Anaconda can be the best solution for Windows users.

List of all modules: https://docs.continuum.io/anaconda/pkg-docs

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

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.11, use lxml‑4.9.0‑cp311‑cp311‑win32.whl.

Download the file, and then install with:

pip install C:\path\to\downloaded\file\lxml‑4.9.0‑cp311‑cp311‑win32.whl

Can't install python lxml (and libxml2) on windows

You can try the binary from here.
First do pip install wheel and then pip install <filename.whl> to install the downloaded binary.



Related Topics



Leave a reply



Submit