Skip to main content

Lxml

The lxml XML toolkit is a Pythonic binding for the C libraries libxml2 and libxslt. It is used by any of our Python tools that either digest or output xml or html data. It is recommended that you install lxml prior to using any of our Python tools or else unexpected behavior may occur.

Installing lxml

There are two big obstacles to installing lxml on a Mac. First, the Mac standard libxml2 is often woefully out of date (at least up to 10.7; 10.8 is far better.) Therefore, in order to get a good version of libxml2, the creators of lxml built in a way to build a static library of libxml2 into your compilation. Unfortunately, the latest version of libxml2 at this time of writing (2.9.0) has a bug, preventing usual tools like "pip" from working. (If 2.9.1 is ever released, then STATIC_DEPS=true pip install lxml will work. If you need sudo, remember to put it between sudo and pip).

  1. Download The latest version of lxml from PyPi: http://pypi.python.org/pypi/lxml
  2. Untar it, cd to the new folder, and execute python setup.py build --static-deps --libxml2-version=2.8.0. You may need sudo permissions, depending on your setup.