Reputation: 53
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 following error:
Collecting libxml2-python3 Using cached
https://files.pythonhosted.org/packages/41/97/a2ecf6c5b291799dbd40b3d041d89b0ecdb1b43c8c2503e27991325851cd/libxml2-python3-2.9.5.tar.gz
Complete output from command python setup.py egg_info:
failed to find headers for libxml2: update includes_dir
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in
/tmp/pip-install-72u9ke0y/libxml2-python3/
I tried the solutions provided in the following links but nothing works for me :
https://github.com/GoogleCloudPlatform/google-cloud-python/issues/3884
"pip install unroll": "python setup.py egg_info" failed with error code 1
How to install libxml2 in virtualenv?
i work on fedora 27 os
Upvotes: 5
Views: 5766
Reputation: 79
I hit similar situation, my linux is Ubuntu on Windows 10 (WSL - Windows Subsystem for Linux)
What I did to solve the issue is:
me@WSL:~/$ sudo apt-get update
me@WSL:~/$ sudo apt install python3 python3-pip libxml2 libxml2-dev
me@WSL:~/$ pip3 install libxml2-python3
Upvotes: 1
Reputation: 16912
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: [email protected]
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.)
Upvotes: 0
Reputation: 6010
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.
Upvotes: 2
Reputation: 135
If I'm not mistaken, you would need the libxml2 development files. Try running
yum install libxml2-devel
then run the pip install again
Upvotes: 2