Thursday, January 15, 2009

Installing Python 2.4 and libxml2 on Mac OS X 10.5 (Leopard) for Plone

I've had quite the struggle with getting libxml2 and related libraries installed on my Mac OS X (10.5 - Leopard) . Thanks to Brent Lambert of enPraxis recommending MacPorts, I have finally managed to stumble my way through the hoops and hurdles to have a successful installation with all the pieces working for developing with Plone on my Mac.

I come from a background of working on and programming websites and think Plone is a fascinating, sophisticated, top-notch solution for content management. I also think it's a great platform for developing web applications, but find the initial learning curve to be almost prohibitively steep. I see the promised land on the other side of the ridge, but am still struggling to get there. Maybe you can relate.

I'm proficient on Unix and with simple shell usage, commands, etc... but I've never fully followed the gory details of compiling libraries and the like. Generally I issue the ./configure, make, sudo make install commands, cross my fingers and hope for the best. I follow-up on any error messages I can decode, but there's still a seemingly black-hole of mystery surrounding the compliation process. At this point I've actually lost track of the number of Python installations on my system (OS X 10.5 seems to come with Python 2.3 and 2.5, the Plone distribution for Mac comes with Python 2.4, I compiled one, found another download, etc...) and I had a similar experience with downloading, compiling and installing libxml2.

Since Zope requires Python 2.4 and Plone is built on Zope, there's a version induced nightmare (well, maybe that's stating it a little strongly, but you get the gist, yes?). The version needs were particularly problematic since Leopard comes with an older version of libxml2 and a newer version of Python, etc...

This is still a bit of a mystery to me, but rather than detail all the things that didn't work, here's what worked for me:
  1. Install Apple's Xcode (required by MacPorts).
  2. Install MacPorts.
  3. Run these commands, roughly in the below order:
sudo port install python24
sudo port install python_select
sudo python_select python24
sudo port install libxml2
sudo port install libxslt
sudo port install py-libxml2
Other commands I ran which may be necessary for Plone:
sudo port install py-xml
sudo port install py-elementtree
sudo port install py-setuptools
sudo port install py-lxml
sudo port install py-pil
I know it's a bit of a shotgun approach and since I had already made a mess of my system I had to issue some relinking to make Python 2.4 the default (ln -sf /opt/local/bin/python2.4 /usr/local/bin/python, for example). A lot of this is voodoo to me. If the commands work, great, if not, I follow up with the erorr messages in google and attempt to piece it all together. I'm not uber-concerned with what side-effects this may have on my system. I just know it now works for me.

I hope this helped!


  1. Yeah, painful. My experience was similar, although I went with MacPorts from the very start.

  2. That's what being new to Mac did for me... I thought: why do I have to use all of these add-ons? I was at odds with the need for MacPorts when I began and found other write-ups that I could never get to work as they described. Mostly these were lengthy multi-step processes that were, to this Mac novice and amateur linux enthusiast, complicated.

    Although the libraries seem to be installed and used, I'm getting errors with the target Plone product. The developers of IMSTransport have been really helpful, but I'm still not getting it to work as I've hoped to.

    I killed my Mac today in the clean-up process. For those of you considering tampering with `/usr/lib/libxml2.2.dylib` ... DON'T!!! I couldn't even boot to single user mode after moving this key file out of its cozy home. It's a key system file. Do what you can to leave it be!

  3. isn't it ridiculous that we can't update a library on the system with a newer version?

    Mac should be supporting Python for all it's worth. This business of insane configuration problems is getting really, really old for me.

  4. What I’m looking for are instructions for building libxml2 as a universal binary (PPC and Intel, 32 and 64-bit — so 4 binaries in one library). The libxml2 library is used all over the system, both in Intel and Rosetta (PPC) processes. So when I did a non-universal build from the source, all of my Rosetta apps would crash on run.

    So, if a comprehensive universal binary can be built, I’m guessing it would work for everything in the system.

  5. I found a page that discusses just what I was looking for:
    Building Mac OS X Universal Binary Open Source Packages by Mark Liyanage (which also refers to Apple’s Technical Note TN2137: Building Universal Binaries from "configure"-based Open Source Projects).

  6. Hey Mark saw your post:{EduTrades (Teach Me To Trade, TMTT, Wealth Intelligence Academy, etc...)} not sure of this training hope it is of the best for the price. I find most are up and running techniques rather tha a trading plan.
    any how you can use this source for you and readers for a affodable trading system taught by a 20 year vetran at Teach Me to Trade Course:
    at; http//