108
  1. I am running the following comand for installing the packages in that file " pip install -r requirements.txt --download-cache=~/tmp/pip-cache".

  2. requirement.txt contains pacakages like

# Data formats
# ------------
PIL==1.1.7 # 

html5lib==0.90
httplib2==0.7.4
lxml==2.3.1

# Documentation
# -------------
Sphinx==1.1
docutils==0.8.1

# Testing
# -------
behave==1.1.0
dingus==0.3.2
django-testscenarios==0.7.2
mechanize==0.2.5
mock==0.7.2
testscenarios==0.2
testtools==0.9.14
wsgi_intercept==0.5.1

while comming to install "lxml" packages i am getting the following eror

Requirement already satisfied (use --upgrade to upgrade): django-testproject>=0.1.1 in /usr/lib/python2.7/site-packages/django_testproject-0.1.1-py2.7.egg (from django-testscenarios==0.7.2->-r requirements.txt (line 33))
Installing collected packages: lxml, Sphinx, docutils, behave, dingus, mock, testscenarios, testtools, South
  Running setup.py install for lxml
    Building lxml version 2.3.1.
    Building without Cython.
    ERROR: /bin/sh: xslt-config: command not found

    ** make sure the development packages of libxml2 and libxslt are installed **

    Using build configuration of libxslt
    building 'lxml.etree' extension
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -D_GNU_SOURCE -fPIC -fwrapv -fPIC -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:
    src/lxml/etree_defs.h:9:31: fatal error: libxml/xmlversion.h: No such file or directory
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    Complete output from command /usr/bin/python -c "import setuptools;__file__='/root/Projects/ir/build/lxml/setup.py';execfile(__file__)" install --single-version-externally-managed --record /tmp/pip-SwjFm3-record/install-record.txt:
    Building lxml version 2.3.1.

Building without Cython.

ERROR: /bin/sh: xslt-config: command 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

copying src/lxml/cssselect.py -> build/lib.linux-i686-2.7/lxml

copying src/lxml/__init__.py -> build/lib.linux-i686-2.7/lxml

copying src/lxml/sax.py -> build/lib.linux-i686-2.7/lxml

copying src/lxml/pyclasslookup.py -> build/lib.linux-i686-2.7/lxml

copying src/lxml/usedoctest.py -> build/lib.linux-i686-2.7/lxml

copying src/lxml/doctestcompare.py -> build/lib.linux-i686-2.7/lxml

copying src/lxml/_elementpath.py -> build/lib.linux-i686-2.7/lxml

copying src/lxml/ElementInclude.py -> build/lib.linux-i686-2.7/lxml

copying src/lxml/builder.py -> build/lib.linux-i686-2.7/lxml

copying src/lxml/html/clean.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/_dictmixin.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/usedoctest.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/builder.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/diff.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/_diffcommand.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/soupparser.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/isoschematron/__init__.py -> build/lib.linux-i686-2.7/lxml/isoschematron

copying src/lxml/etreepublic.pxd -> build/lib.linux-i686-2.7/lxml

copying src/lxml/tree.pxd -> build/lib.linux-i686-2.7/lxml

copying src/lxml/etree_defs.h -> build/lib.linux-i686-2.7/lxml

copying src/lxml/isoschematron/resources/rng/iso-schematron.rng -> build/lib.linux-i686-2.7/lxml/isoschematron/resources/rng

copying src/lxml/isoschematron/resources/xsl/XSD2Schtrn.xsl -> 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/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/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_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_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/readme.txt -> build/lib.linux-i686-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1

running build_ext

building 'lxml.etree' extension

gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -D_GNU_SOURCE -fPIC -fwrapv -fPIC -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:

src/lxml/etree_defs.h:9:31: fatal error: libxml/xmlversion.h: No such file or directory

compilation terminated.

error: command 'gcc' failed with exit status 1

----------------------------------------
Command /usr/bin/python -c "import setuptools;__file__='/root/Projects/ir/build/lxml/setup.py';execfile(__file__)" install --single-version-externally-managed --record /tmp/pip-SwjFm3-record/install-record.txt failed with error code 1
Storing complete log in /root/.pip/pip.log

Can anyone check and guide me what would be the problem and why?Any package missing to install.

Jonathon Reinhart
  • 132,704
  • 33
  • 254
  • 328
user2086641
  • 4,331
  • 13
  • 56
  • 96

5 Answers5

259

Install libxslt-devel & libxml2-devel using

sudo apt-get install libxml2-dev libxslt1-dev

After installing follow the above one

Monk L
  • 3,358
  • 9
  • 26
  • 41
  • 3
    Notice for Ubuntu 13.04 users: if you have libxml2 already installed and upgraded to version 2.9.0+dfsg1-4ubuntu4.3 you need to downgrade it to 2.9.0+dfsg1-4ubuntu4.1 by typing the command sudo apt-get install libxml2=2.9.0+dfsg1-4ubuntu4.1 otherwise the libxml2-dev wont be installed due version dependency. – HXH Sep 17 '13 at 08:58
  • What is the different between libxml2 and libxml? Thanks! – Honghe.Wu Mar 12 '14 at 06:45
  • @Honghe.Wu here you can find the difference details: http://xmlsoft.org/FAQ.html. In short, go for libxml2 – kmonsoor Nov 26 '14 at 05:59
  • after performing this it gives below error : EnvironmentError: mysql_config not found – Divyang Shah Jun 10 '15 at 13:01
  • 10
    I installed the two libraries, and still got the error. Logged off and back on, and still got the error. The make file is looking in /usr/include for libxml, but that is nested inside a libxml2 directory. Linking to libxml from /usr/include did the trick `sudo ln -s libxml2/libxml libxml`. – foszter Aug 11 '15 at 09:34
  • 1
    this is the answer for Debian Jessie too – Anentropic Oct 07 '15 at 11:12
  • 4
    For those using Alpine Linux (probably in Docker), the command is: apk add install libxml2-dev libxslt-dev – ivarec Jan 04 '19 at 00:02
56
  1. Install Cython using

    easy_install Cython

  2. After completion of cython, install libxslt-devel & libxml2-devel using

    yum install libxslt-devel libxml2-devel

This worked for me.

Sean
  • 4,365
  • 1
  • 27
  • 31
user2086641
  • 4,331
  • 13
  • 56
  • 96
  • 3
    This is actually the correct answer (use sudo apt-get debian/ubuntu) – roshan Jun 05 '13 at 04:02
  • 2
    @roshan: right, sudo apt-get install libxml2-dev libxslt1-dev – Joel Sjögren Jul 16 '13 at 16:47
  • 5
    for amazon linux, `sudo yum install libxslt-devel libxml2-devell` solved for me, thx – Cmag Apr 28 '14 at 00:42
  • Cython was the missing link for me, after installing the libraries. It's just `-dev` for the packages on Raspbian though. Installing cython was tricky... I ended up having to use `sudo pip3 install Cython --install-option="--no-cython-compile"` for it to work properly. `sudo pip3 install Cython` alone crashed, and `easy_install3` didn't do anything – Zoe Feb 16 '19 at 16:27
10

The selected answer is right but I just wanted to add for those who use Fedora: libxslt1 is called libxslt when using dnf. So the command is:

sudo dnf install libxml2-devel libxslt-devel

devel for dnf is the same as dev for apt-get.

tleb
  • 4,395
  • 3
  • 25
  • 33
7

The certified answer works perfectly. But just adding the installation command for alpine to install libxslt-devel & libxml2-devel

apk add --update libxml2-dev libxslt-dev
Ojus sangoi
  • 636
  • 7
  • 7
6

without sudo rights you can install lxml with:

STATIC_DEPS=true pip install lxml

As mentioned in the lxml documentation

cybfox
  • 198
  • 2
  • 8