Table of Contents
lxml is one of the best ways of parsing XML in Python. It is not trivial to install on all platforms however.
Linux#
System Requirements#
$ sudo apt-get install libxslt1.1 libxslt1-dev libxml2-dev libxml2
Python Packages#
$ sudo pip install Cython $ sudo pip install lxml
Mac#
Cython#
Install Cython
sudo easy_install Cython
libxml2#
The version of libxml2 that comes with Leopard is too old.
./configure --prefix=/usr/local/libxml2-2.7.1 make sudo make install cd /Library/Python/2.5/site-packages sudo ln -s /usr/local/libxml2-2.7.1/lib/python2.5/site-packages/* .
libxslt#
The version of libxslt that comes with Leopard is too old.
./configure --prefix=/usr/local/libxslt-1.1.24 --with-libxml-prefix=/usr/local/libxml2-2.7.1 make sudo make install cd /Library/Python/2.5/site-packages sudo ln -s /usr/local/libxslt-1.1.24/lib/python2.5/site-packages/* .
lxml#
Download and install lxml
sudo python setup.py install \ --with-xml2-config=/usr/local/libxml2-2.7.1/bin/xml2-config \ --with-xslt-config=/usr/local/libxslt-1.1.24/bin/xslt-config
Notes#
Mostly taken from
http://lsimons.wordpress.com/2008/08/31/how-to-install-lxml-python-module-on-mac-os-105-leopard/
Python.Mac - Python.Linux