PIL with libjpeg on OS X Snow Leopard

PIL was nice to have, until something changed and I started getting an error. If you are here, you are probably seeing this error:

The _imaging C module is not installed

It sounds like the problem is native python in Snow Leopard runs 32 bit instead of 64, while libjpeg is made to run in 64.  I don't know if that's what I ran into, or exactly what my particular problem was, but I finally fixed it.  The exact steps I took are a bit blurry since I tried so many different ways to install and configure libjpeb with several different versions.  So somewhere I may have done something that helped, but here are the final steps I took before getting it all to work.

You'll need libjpeg/libpng combo dmg from here: http://ethan.tira-thompson.org/Mac_OS_X_Ports.html

  1. Uninstall PIL: 'pip uninstall PIL`  (I suppose this assumes you installed via pip and that you have it installed in the first place)
  2. Install PIL in 64 bit mode `ARCHFLAGS="-arch i386 -arch x86_64" sudo pip install PIL`
  3. Install the libjpeg/libpng combo dmg
That did it for me. Verify with:
>>> import PIL
>>> import Image
>>> import _imaging
>>> 
>>> import PIL
>>> import Image
>>> import _imaging
>>> 

I apologize for being short on details, but I tried so many different things and I tried this not thinking it'd work and it did.  Hopefully it helps someone, but if not at least I have notes for myself. :P