Problems installing lxml on Ubuntu

Getting the following errors: pip install lxml

You are using pip version 6.0.8, however version 7.1.0 is available. You should consider upgrading via the 'pip install --upgrade pip' command. Collecting lxml Using cached lxml-3.4.4.tar.gz /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url' warnings.warn(msg) Building lxml version 3.4.4. Building without Cython. ERROR: /bin/sh: 1: xslt-config: not found ** make sure the development packages of libxml2 and libxslt are installed ** Using build configuration of libxslt Installing collected packages: lxml Running setup.py install for lxml /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url' warnings.warn(msg) Building lxml version 3.4.4. Building without Cython. ERROR: /bin/sh: 1: xslt-config: not found ** make sure the development packages of libxml2 and libxslt are installed ** Using build configuration of libxslt building 'lxml.etree' extension i686-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/tmp/pip-build-RLyvkw/lxml/src/lxml/includes -I/usr/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-i686-2.7/src/lxml/lxml.etree.o -w In file included from src/lxml/lxml.etree.c:239:0: /tmp/pip-build-RLyvkw/lxml/src/lxml/includes/etree_defs.h:14:31: fatal error: libxml/xmlversion.h: No such file or directory #include "libxml/xmlversion.h" ^ compilation terminated. error: command 'i686-linux-gnu-gcc' failed with exit status 1 Complete output from command /home/apurva/.virtualenvs/universallogin/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-RLyvkw/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-9WRQzF-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/apurva/.virtualenvs/universallogin/include/site/python2.7: /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url' warnings.warn(msg) Building lxml version 3.4.4. Building without Cython. ERROR: /bin/sh: 1: xslt-config: not found ** make sure the development packages of libxml2 and libxslt are installed ** Using build configuration of libxslt running install running build running build_py creating build creating build/lib.linux-i686-2.7 creating build/lib.linux-i686-2.7/lxml copying src/lxml/pyclasslookup.py -> build/lib.linux-i686-2.7/lxml copying src/lxml/doctestcompare.py -> build/lib.linux-i686-2.7/lxml copying src/lxml/sax.py -> build/lib.linux-i686-2.7/lxml copying src/lxml/_elementpath.py -> build/lib.linux-i686-2.7/lxml copying src/lxml/__init__.py -> build/lib.linux-i686-2.7/lxml copying src/lxml/builder.py -> build/lib.linux-i686-2.7/lxml copying src/lxml/ElementInclude.py -> build/lib.linux-i686-2.7/lxml copying src/lxml/cssselect.py -> build/lib.linux-i686-2.7/lxml copying src/lxml/usedoctest.py -> build/lib.linux-i686-2.7/lxml creating build/lib.linux-i686-2.7/lxml/includes copying src/lxml/includes/__init__.py -> build/lib.linux-i686-2.7/lxml/includes creating build/lib.linux-i686-2.7/lxml/html copying src/lxml/html/soupparser.py -> build/lib.linux-i686-2.7/lxml/html copying src/lxml/html/html5parser.py -> build/lib.linux-i686-2.7/lxml/html copying src/lxml/html/_setmixin.py -> build/lib.linux-i686-2.7/lxml/html copying src/lxml/html/diff.py -> build/lib.linux-i686-2.7/lxml/html copying src/lxml/html/formfill.py -> build/lib.linux-i686-2.7/lxml/html copying src/lxml/html/_diffcommand.py -> build/lib.linux-i686-2.7/lxml/html copying src/lxml/html/ElementSoup.py -> build/lib.linux-i686-2.7/lxml/html copying src/lxml/html/__init__.py -> build/lib.linux-i686-2.7/lxml/html copying src/lxml/html/builder.py -> build/lib.linux-i686-2.7/lxml/html copying src/lxml/html/defs.py -> build/lib.linux-i686-2.7/lxml/html copying src/lxml/html/_html5builder.py -> build/lib.linux-i686-2.7/lxml/html copying src/lxml/html/usedoctest.py -> build/lib.linux-i686-2.7/lxml/html copying src/lxml/html/clean.py -> build/lib.linux-i686-2.7/lxml/html creating build/lib.linux-i686-2.7/lxml/isoschematron copying src/lxml/isoschematron/__init__.py -> build/lib.linux-i686-2.7/lxml/isoschematron copying src/lxml/lxml.etree.h -> build/lib.linux-i686-2.7/lxml copying src/lxml/lxml.etree_api.h -> build/lib.linux-i686-2.7/lxml copying src/lxml/includes/htmlparser.pxd -> build/lib.linux-i686-2.7/lxml/includes copying src/lxml/includes/xinclude.pxd -> build/lib.linux-i686-2.7/lxml/includes copying src/lxml/includes/c14n.pxd -> build/lib.linux-i686-2.7/lxml/includes copying src/lxml/includes/xpath.pxd -> build/lib.linux-i686-2.7/lxml/includes copying src/lxml/includes/etreepublic.pxd -> build/lib.linux-i686-2.7/lxml/includes copying src/lxml/includes/schematron.pxd -> build/lib.linux-i686-2.7/lxml/includes copying src/lxml/includes/xslt.pxd -> build/lib.linux-i686-2.7/lxml/includes copying src/lxml/includes/tree.pxd -> build/lib.linux-i686-2.7/lxml/includes copying src/lxml/includes/config.pxd -> build/lib.linux-i686-2.7/lxml/includes copying src/lxml/includes/xmlschema.pxd -> build/lib.linux-i686-2.7/lxml/includes copying src/lxml/includes/xmlerror.pxd -> build/lib.linux-i686-2.7/lxml/includes copying src/lxml/includes/xmlparser.pxd -> build/lib.linux-i686-2.7/lxml/includes copying src/lxml/includes/dtdvalid.pxd -> build/lib.linux-i686-2.7/lxml/includes copying src/lxml/includes/uri.pxd -> build/lib.linux-i686-2.7/lxml/includes copying src/lxml/includes/relaxng.pxd -> build/lib.linux-i686-2.7/lxml/includes copying src/lxml/includes/etree_defs.h -> build/lib.linux-i686-2.7/lxml/includes copying src/lxml/includes/lxml-version.h -> build/lib.linux-i686-2.7/lxml/includes creating build/lib.linux-i686-2.7/lxml/isoschematron/resources creating build/lib.linux-i686-2.7/lxml/isoschematron/resources/rng copying src/lxml/isoschematron/resources/rng/iso-schematron.rng -> build/lib.linux-i686-2.7/lxml/isoschematron/resources/rng creating build/lib.linux-i686-2.7/lxml/isoschematron/resources/xsl copying src/lxml/isoschematron/resources/xsl/RNG2Schtrn.xsl -> build/lib.linux-i686-2.7/lxml/isoschematron/resources/xsl copying src/lxml/isoschematron/resources/xsl/XSD2Schtrn.xsl -> build/lib.linux-i686-2.7/lxml/isoschematron/resources/xsl creating build/lib.linux-i686-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1 copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_dsdl_include.xsl -> build/lib.linux-i686-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1 copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_abstract_expand.xsl -> build/lib.linux-i686-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1 copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_message.xsl -> build/lib.linux-i686-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1 copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_skeleton_for_xslt1.xsl -> build/lib.linux-i686-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1 copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_svrl_for_xslt1.xsl -> build/lib.linux-i686-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1 copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/readme.txt -> build/lib.linux-i686-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1 running build_ext building 'lxml.etree' extension creating build/temp.linux-i686-2.7 creating build/temp.linux-i686-2.7/src creating build/temp.linux-i686-2.7/src/lxml i686-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/tmp/pip-build-RLyvkw/lxml/src/lxml/includes -I/usr/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-i686-2.7/src/lxml/lxml.etree.o -w In file included from src/lxml/lxml.etree.c:239:0: /tmp/pip-build-RLyvkw/lxml/src/lxml/includes/etree_defs.h:14:31: fatal error: libxml/xmlversion.h: No such file or directory #include "libxml/xmlversion.h" ^ compilation terminated. error: command 'i686-linux-gnu-gcc' failed with exit status 1 ---------------------------------------- Command "/home/apurva/.virtualenvs/universallogin/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-RLyvkw/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-9WRQzF-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/apurva/.virtualenvs/universallogin/include/site/python2.7" failed with error code 1 in /tmp/pip-build-RLyvkw/lxml 

I already tried this: sudo apt-get install zlib1g-dev before pip install reads this answer: Failed to install lxml verison 3.3.5 in ubuntu

but it didnโ€™t help. Also, trying to install python-dev, python3-dev, lib-eventdev didnโ€™t help either.

Also tried to do this: STATIC_DEPS = true pip install lxml this: http://lxml.de/installation.html

Did not help! We would be very grateful if you could offer something Thank you in advance.

+7
python pip lxml
source share
2 answers

if you donโ€™t need a specific version from PyPI, you can always use the version packaged for Ubuntu.

 $ sudo apt-get install python-lxml 

... and then allow system site packages in your virtual directory.


update:

to clarify ... By default, python packages are installed from PyPI. However, many python packages are also packaged for Ubuntu and stored in Ubuntu archives, you can install them through the system package manager (apt-get) instead of using pip. This can be useful since Ubuntu packages are already compiled and will pull any dependencies they need.

By default, virtualenv creates a python sandbox, so you donโ€™t have access to the system packages (which you installed with apt-get). However, you can enable system site packages in your virtual directory.

for example, let it install lxml from it into a system package, create a virtualenv named "ENV", which allows access to system packages, and then import lxml to check its functionality:

 $ sudo apt-get install python-lxml $ virtualenv --system-site-packages ENV $ source ENV/bin/activate (ENV)$ python -c "import xml" 
+3
source share

Output Status ** make sure the development packages of libxml2 and libxslt are installed ** . Did you do it?

 sudo apt-get install libxml2-dev libxslt-dev 

Also, is there a specific reason why you install with pip instead of installing the python-lxml package that comes with Ubuntu? Installing your distribution should be preferred if you have no reason to.

+19
source share

All Articles