Skip to content Skip to sidebar Skip to footer

Cannot Install Libxml2 In Virtualenv

I have got an issue with libxml2 python module. I'm trying to install it on a python3 virtualenv using the following command: pip install libxml2-python3 but it shows the followin

Solution 1:

If I'm not mistaken, you would need the libxml2 development files. Try running

yum install libxml2-devel

then run the pip install again

Solution 2:

It's installed with lxml, in fact you probably want to use lxml instead of libxml2 because lxml is based on libxml2 is more pythonic:

sudo pip install lxml

libxml2 page says:

Note that some of the Python purist dislike the default set of Python bindings, rather than complaining I suggest they have a look at lxml the more pythonic bindings for libxml2 and libxslt and check the mailing-list.

lxml page says:

The lxml XML toolkit is a Pythonic binding for the C libraries libxml2 and libxslt. It is unique in that it combines the speed and XML feature completeness of these libraries with the simplicity of a native Python API, mostly compatible but superior to the well-known ElementTree API. The latest release works with all CPython versions from 2.6 to 3.6. See the introduction for more information about background and goals of the lxml project. Some common questions are answered in the FAQ.

Solution 3:

I hit similar situation, my linux is Ubuntu on Windows 10 (WSL - Windows Subsystem for Linux)

What I did to solve the issue is:

  1. Using apt, install: python3 python3-pip, libxml2 libxml2-dev.
me@WSL:~/$ sudo apt-get update
me@WSL:~/$ sudo apt install python3 python3-pip libxml2 libxml2-dev
  1. Using installed pip, install libxml2-python
    me@WSL:~/$ pip3 install libxml2-python3
  1. done. hope this notes help you.

Solution 4:

Yeah, I got the same error after trying to update the lmxl pip package. The problem is that lxml depends on both libmxl2 and libxslt development libraries. Therefore you need to make sure they are installed first.

# pip3 show lxml
Name: lxml
Version: 4.2.5
Summary: Powerful and Pythonic XML processing library combining libxml2/libxslt with the ElementTree API.
Home-page: http://lxml.de/
Author: lxml dev team
Author-email: lxml-dev@lxml.de
License: BSD
Location: /usr/lib/python3.6/site-packages
Requires:
Required-by: Scrapy, parsel, [etc etc]

So install the packages along the line with:

apt-get install libxml2-devel libxslt-devel

(And whatever they depend on in turn.)

Post a Comment for "Cannot Install Libxml2 In Virtualenv"