Skip to main content

HOWTO: Install lxml on Mac OSX

lxml is a total nightmare to install on the Mac. For my own future sanity, this is how to do it.
  • Install MacPorts
  • Install libxml2: sudo port install libxml2
  • Install libxslt: sudo port install libxslt
  • Make sure DYLD_LIBRARY_PATH includes /opt/local/lib (I am a unix n00b and just edit ~/.bash_profile to have the lines:

    in it and restart the shell)
  • Get the lxml code: svn co lxml
  • Install Easy_Install (surely you've done this already!)
  • Install Cython: easy_install Cython==
  • In the lxml folder run python build --with-xslt-config=/opt/local/bin/xslt-config
  • Then python install
  • Look puzzled when python fails utterly
  • Shrug that off quickly when lxml works generally
This is for Tiger, it may work on other versions too.


bollwyvl said…
Thanks for the recipe! Bookmarked!


sudo port install libxlst

should read

sudo port install libxslt
Jamie said…
Thanks for this - after hours of dud XML libraries for python lxml looks great - and this was the help I needed to actually get it working.
Thanks for this, saved me some hassle!



should read


Popular posts from this blog

Citeable Blockquotes

I use some javascript to make the citations in my blockquotes clickable. It's all very well but it doesn't exactly help for general browsing.

So, with a little more Greasemonkeying, we have Blockquote Citations.

It works by adding a link to the citation if it appears to be a url. It will use the blockquote's title as the link text or "source" if there isn't a title.

It will not add the link if there is already a visible link to the same URL - the idea being we don't want to make pages unreadable if people already have gone to the trouble of linking to their source either manually or with script.

This blog has the blockquote citations script inline, but you can test your installation of the script on this handy test page.