Thursday, April 22, 2010

Python Image Library - Part 1

I love Python. I love it's simplicity and immediate gratification in the form of immediate result without endless makefiles and compilation errors. So, for one of my unreasonable project ideas I have decided to use Python - especially since I finally managed to get down to the Interface Builder and Cocoa programming that I've been avoiding and that I'm starting to get a hang of.

One part of the project receives camera frame images in a packed binary format. Luckily, I have found some code online that shift-unpacks it into a buffer that can then be directly passed to the PIL Image class. So, now all I have to do is get PIL onto my Snow Leopard. Sounds simple, right?

Welll..... This is where it all started going bad. I got bit by (turns out infamous) "***The _imaging C module is not installed" error. There seems to be a small number of possible fixes that have worked for some but not others that have encountered it. The solutions ranged from re-installing all involved libraries to downgrading to libjped6b (while current version is 8) to force-recompiling everything into 32 bits. I've tried them all except for the 32 bit suggestion - I just migrated all my libraries to 64 bit after upgrading from OS 10.5 to 10.6 and I wasn't about to start messing it all up again.

So, after days of looking for alternatives I decided to give it another day. On one of the posts that I found someone stated that PIL is asking for libjpeg6b specifically and you cannot expect it to work with version 7! So I fink downloaded version 6b, pointed the JPEG_ROOT to /sw/lib, etc. Guess what - it didn't work. In fact, it got all unhappy as version 6b has wrong architecture!

Then I had a moment of enlightenment - "fink remove libjpeg, libjpeg-bin, libjpeg-shlibs" (My shlibs failed to remove because of numerous dependencies but the most important thing is that the other two are NOT on your system). I went through all the places that could have retained any old version of libjpeg making sure to remove them all. Once I had only the latest libjpeg left compiled for x86_64 (which happens by default on 10.6) PIL build worked.

So there you have it. Hope this helps someone else out there tearing through the good, the bad, and the ugly of open source.

No comments:

Post a Comment