0

I tried to install lxml on my mac (yosemite) with pip install lxml and got the below error message. I tried this in my virtualenv as well as system wide with the same result. My virtualenv is Python3 and systemwide I tried it with both pip and pip3. I have no idea what to make of the error.

(testenv3)testenv3 > pip install lxml
Collecting lxml
  Using cached lxml-3.4.4.tar.gz
Installing collected packages: lxml
  Running setup.py install for lxml
    Complete output from command /Users/mmarotta/.virtualenvs/testenv3/bin/python3.4 -c "import setuptools, tokenize;__file__='/private/var/folders/7m/hjg5_zf53nvfhpf9dn8ms7hh0000gn/T/pip-build-dyli2irl/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/7m/hjg5_zf53nvfhpf9dn8ms7hh0000gn/T/pip-r09rujlw-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/mmarotta/.virtualenvs/testenv3/bin/../include/site/python3.4/lxml:
    Building lxml version 3.4.4.
    Building without Cython.
    Using build configuration of libxslt 1.1.28
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.10-x86_64-3.4
    creating build/lib.macosx-10.10-x86_64-3.4/lxml
    copying src/lxml/__init__.py -> build/lib.macosx-10.10-x86_64-3.4/lxml
    copying src/lxml/_elementpath.py -> build/lib.macosx-10.10-x86_64-3.4/lxml
    copying src/lxml/builder.py -> build/lib.macosx-10.10-x86_64-3.4/lxml
    copying src/lxml/cssselect.py -> build/lib.macosx-10.10-x86_64-3.4/lxml
    copying src/lxml/doctestcompare.py -> build/lib.macosx-10.10-x86_64-3.4/lxml
    copying src/lxml/ElementInclude.py -> build/lib.macosx-10.10-x86_64-3.4/lxml
    copying src/lxml/pyclasslookup.py -> build/lib.macosx-10.10-x86_64-3.4/lxml
    copying src/lxml/sax.py -> build/lib.macosx-10.10-x86_64-3.4/lxml
    copying src/lxml/usedoctest.py -> build/lib.macosx-10.10-x86_64-3.4/lxml
    creating build/lib.macosx-10.10-x86_64-3.4/lxml/includes
    copying src/lxml/includes/__init__.py -> build/lib.macosx-10.10-x86_64-3.4/lxml/includes
    creating build/lib.macosx-10.10-x86_64-3.4/lxml/html
    copying src/lxml/html/__init__.py -> build/lib.macosx-10.10-x86_64-3.4/lxml/html
    copying src/lxml/html/_diffcommand.py -> build/lib.macosx-10.10-x86_64-3.4/lxml/html
    copying src/lxml/html/_html5builder.py -> build/lib.macosx-10.10-x86_64-3.4/lxml/html
    copying src/lxml/html/_setmixin.py -> build/lib.macosx-10.10-x86_64-3.4/lxml/html
    copying src/lxml/html/builder.py -> build/lib.macosx-10.10-x86_64-3.4/lxml/html
    copying src/lxml/html/clean.py -> build/lib.macosx-10.10-x86_64-3.4/lxml/html
    copying src/lxml/html/defs.py -> build/lib.macosx-10.10-x86_64-3.4/lxml/html
    copying src/lxml/html/diff.py -> build/lib.macosx-10.10-x86_64-3.4/lxml/html
    copying src/lxml/html/ElementSoup.py -> build/lib.macosx-10.10-x86_64-3.4/lxml/html
    copying src/lxml/html/formfill.py -> build/lib.macosx-10.10-x86_64-3.4/lxml/html
    copying src/lxml/html/html5parser.py -> build/lib.macosx-10.10-x86_64-3.4/lxml/html
    copying src/lxml/html/soupparser.py -> build/lib.macosx-10.10-x86_64-3.4/lxml/html
    copying src/lxml/html/usedoctest.py -> build/lib.macosx-10.10-x86_64-3.4/lxml/html
    creating build/lib.macosx-10.10-x86_64-3.4/lxml/isoschematron
    copying src/lxml/isoschematron/__init__.py -> build/lib.macosx-10.10-x86_64-3.4/lxml/isoschematron
    copying src/lxml/lxml.etree.h -> build/lib.macosx-10.10-x86_64-3.4/lxml
    copying src/lxml/lxml.etree_api.h -> build/lib.macosx-10.10-x86_64-3.4/lxml
    copying src/lxml/includes/c14n.pxd -> build/lib.macosx-10.10-x86_64-3.4/lxml/includes
    copying src/lxml/includes/config.pxd -> build/lib.macosx-10.10-x86_64-3.4/lxml/includes
    copying src/lxml/includes/dtdvalid.pxd -> build/lib.macosx-10.10-x86_64-3.4/lxml/includes
    copying src/lxml/includes/etreepublic.pxd -> build/lib.macosx-10.10-x86_64-3.4/lxml/includes
    copying src/lxml/includes/htmlparser.pxd -> build/lib.macosx-10.10-x86_64-3.4/lxml/includes
    copying src/lxml/includes/relaxng.pxd -> build/lib.macosx-10.10-x86_64-3.4/lxml/includes
    copying src/lxml/includes/schematron.pxd -> build/lib.macosx-10.10-x86_64-3.4/lxml/includes
    copying src/lxml/includes/tree.pxd -> build/lib.macosx-10.10-x86_64-3.4/lxml/includes
    copying src/lxml/includes/uri.pxd -> build/lib.macosx-10.10-x86_64-3.4/lxml/includes
    copying src/lxml/includes/xinclude.pxd -> build/lib.macosx-10.10-x86_64-3.4/lxml/includes
    copying src/lxml/includes/xmlerror.pxd -> build/lib.macosx-10.10-x86_64-3.4/lxml/includes
    copying src/lxml/includes/xmlparser.pxd -> build/lib.macosx-10.10-x86_64-3.4/lxml/includes
    copying src/lxml/includes/xmlschema.pxd -> build/lib.macosx-10.10-x86_64-3.4/lxml/includes
    copying src/lxml/includes/xpath.pxd -> build/lib.macosx-10.10-x86_64-3.4/lxml/includes
    copying src/lxml/includes/xslt.pxd -> build/lib.macosx-10.10-x86_64-3.4/lxml/includes
    copying src/lxml/includes/etree_defs.h -> build/lib.macosx-10.10-x86_64-3.4/lxml/includes
    copying src/lxml/includes/lxml-version.h -> build/lib.macosx-10.10-x86_64-3.4/lxml/includes
    creating build/lib.macosx-10.10-x86_64-3.4/lxml/isoschematron/resources
    creating build/lib.macosx-10.10-x86_64-3.4/lxml/isoschematron/resources/rng
    copying src/lxml/isoschematron/resources/rng/iso-schematron.rng -> build/lib.macosx-10.10-x86_64-3.4/lxml/isoschematron/resources/rng
    creating build/lib.macosx-10.10-x86_64-3.4/lxml/isoschematron/resources/xsl
    copying src/lxml/isoschematron/resources/xsl/RNG2Schtrn.xsl -> build/lib.macosx-10.10-x86_64-3.4/lxml/isoschematron/resources/xsl
    copying src/lxml/isoschematron/resources/xsl/XSD2Schtrn.xsl -> build/lib.macosx-10.10-x86_64-3.4/lxml/isoschematron/resources/xsl
    creating build/lib.macosx-10.10-x86_64-3.4/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_abstract_expand.xsl -> build/lib.macosx-10.10-x86_64-3.4/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_dsdl_include.xsl -> build/lib.macosx-10.10-x86_64-3.4/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_message.xsl -> build/lib.macosx-10.10-x86_64-3.4/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_skeleton_for_xslt1.xsl -> build/lib.macosx-10.10-x86_64-3.4/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_svrl_for_xslt1.xsl -> build/lib.macosx-10.10-x86_64-3.4/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/readme.txt -> build/lib.macosx-10.10-x86_64-3.4/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    running build_ext
    building 'lxml.etree' extension
    creating build/temp.macosx-10.10-x86_64-3.4
    creating build/temp.macosx-10.10-x86_64-3.4/src
    creating build/temp.macosx-10.10-x86_64-3.4/src/lxml
    clang -Wno-unused-result -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/include -I/usr/local/opt/sqlite/include -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -I/usr/include/libxml2 -I/private/var/folders/7m/hjg5_zf53nvfhpf9dn8ms7hh0000gn/T/pip-build-dyli2irl/lxml/src/lxml/includes -I/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/include/python3.4m -c src/lxml/lxml.etree.c -o build/temp.macosx-10.10-x86_64-3.4/src/lxml/lxml.etree.o -w -flat_namespace
    In file included from src/lxml/lxml.etree.c:239:
    /private/var/folders/7m/hjg5_zf53nvfhpf9dn8ms7hh0000gn/T/pip-build-dyli2irl/lxml/src/lxml/includes/etree_defs.h:14:10: fatal error: 'libxml/xmlversion.h' file not found
    #include "libxml/xmlversion.h"
             ^
    1 error generated.
    /usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'bugtrack_url'
      warnings.warn(msg)
    error: command 'clang' failed with exit status 1

    ----------------------------------------
Command "/Users/mmarotta/.virtualenvs/testenv3/bin/python3.4 -c "import setuptools, tokenize;__file__='/private/var/folders/7m/hjg5_zf53nvfhpf9dn8ms7hh0000gn/T/pip-build-dyli2irl/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/7m/hjg5_zf53nvfhpf9dn8ms7hh0000gn/T/pip-r09rujlw-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/mmarotta/.virtualenvs/testenv3/bin/../include/site/python3.4/lxml" failed with error code 1 in /private/var/folders/7m/hjg5_zf53nvfhpf9dn8ms7hh0000gn/T/pip-build-dyli2irl/lxml
truth1ness
  • 4,831
  • 5
  • 21
  • 19
  • 1
    `fatal error: 'libxml/xmlversion.h' file not found` it says. Did you install the libxml2 development headers? – Martijn Pieters Jun 04 '15 at 13:37
  • No, I thought pip takes care of dependencies? How do I do that, `pip install libxml2`? – truth1ness Jun 04 '15 at 13:39
  • 1
    @truth1ness No, it's a [system library](http://www.xmlsoft.org/). [OS X binaries here](http://www.explain.com.au/oss/libxml2xslt.html). – Peter Wood Jun 04 '15 at 13:42
  • 1
    @truth1ness: no, pip can only take care of finding other *Python* packages. compilation dependencies have to be taken care of manually. – Martijn Pieters Jun 04 '15 at 13:43
  • 2
    @PeterWood: OS X bundles the library. What is missing is the development headers. The dupe explains how to install those (have XCode install them for you). – Martijn Pieters Jun 04 '15 at 13:44
  • Before I saw your binary link I tried `brew install libxml2` and `brew link libxml2 --force` but lxml still wouldn't install. Next I tried `STATIC_DEPS=true pip install lxml` in my virtualenv and that got it to install successfully (though I'm not sure what a static install means if someone could explain). Is there a command I can run to test it out? I tried `lxml -v` but got a `command not found` error so I'm still not sure if it's working. – truth1ness Jun 04 '15 at 14:01

0 Answers0