Chances are most readers of the Plucked Chicken will have no idea what I’m writing about here. That’s OK. Just move along.
For anyone who may find this post when searching for Plone and an Import Error, when it claims that the Python Imaging Library is not installed because it can’t import PIL, read on.
I’m just now getting a handle on installing Plone via zc.buildout, with a view toward a migration path from a current install on a somewhat critical web site to the next great thing (TM). I decided to install a custom Python in a custom location, so that zc.buildout and easy_install would be able to do their thing without messing up my system Python installations. So far so good.
The problem came after easy_installing PIL (which isn’t as easy as one might hope), running buildout, and starting Plone. Plone complained that it couldn’t import PIL, implying that PIL was not installed. I first made sure that the Zope instance was running the correct Python install, and then I was baffled. I could verify that PIL was installed by a successful “import Image” in the Python shell, but Plone does not import Image directly. Instead, it imports PIL, or perhaps imports through PIL, as “from PIL import Image”.
Two different ways to import PIL, giving access to the same code. Two different ways to install PIL, with the “easy” one being a little more complex than usual. Putting two and two together, I removed my PIL installation, downloaded a tarball, and ran “python setup.py install”, which uses setuptools without easy_install. Everything worked smoothly. I started a Python shell and tried “import PIL” (which hadn’t worked before). This time it worked. Tried starting the Zope instance. It worked too.
Conclusion: Python Imaging Library and easy_install don’t work together the way PIL and setuptools do, resulting in two different ways to import the PIL code. This may be a PIL bug, or it may be that the egg-creation mechanism in easy_install doesn’t handle the requirements of PIL as it should. Either way, if you intend to use PIL with Plone, you’ll have to install it via setuptools. If there’s a better way, I’d appreciate hearing about it.