Per my previous post, it may be apparent that I’m working on a just-for-fun Django project that uses the Python Image Library (PIL). Overall, it’s pretty easy to set up, but the instructions I found on the internet were just wrong enough to make me have to dig around for 20 minutes getting it to work.
Disclaimer: The above instructions *might* work for you, so feel free to try them first.
Anyway the issue I was having: After installing PIL through the above instructions, I tried to upload an ImageField file through the Django Admin interface. I’d get the following error:
The _imaging C module is not installed
Some quick google-fu led me to this page which explained that Python probably could not find the _imaging module, or else that module wasn’t being loaded correctly. This was strange because I had just installed PIL, and PIL showed up in my sys.path. However, running:
>>> import _imaging
Showed the following message:
ImportError: dlopen(/Library/Python/2.6/site-packages/PIL/_imaging.so, 2): no suitable image found. Did find: /Library/Python/2.6/site-packages/PIL/_imaging.so: mach-o, but wrong architecture
Ah-ha! The original instructions indicated that it was required to change the build flags for a 64 bit architecture, but for me that was not necessary and in fact build incompatible binaries for my system.
For those following along, the correct instructions for my system were as follows:
$ curl -O http://effbot.org/downloads/Imaging-1.1.6.tar.gz $ tar zxf Imaging-1.1.6.tar.gz $ sudo bash # cd Imaging-1.1.6 # python setup.py build # python setup.py install # exit