Skip to content


Why can’t my Google App Engine app find the PIL module?

Specifically, I got the following error:


Exception Type: ImportError
Exception Value: No module named PIL
Exception Location: /Library/Python/2.6/site-packages/django/forms/fields.py in clean, line 495
Python Executable: /usr/bin/python2.6
Python Version: 2.6.1
Python Path: [..., '/Library/Python/2.6/site-packages', '/Library/Python/2.6/site-packages/PIL']

Hmmm, a little stuck at this point. It’s clearly in my python path.  So I turned to my favorite programming resource, Stack Overflow, and posted this question.  Well, as it turns out there’s one thing I should’ve known and another more subtle detail.  The first, obvious thing was that of course if PIL is installed in my Python site packages, of course Google App Engine (GAE) can’t access it.  Maybe it could in my environment, but of course in production, I’m in a sandbox, so that’s definitely not going to work!  The second revelation was that PIL won’t work because it’s a C-based library and everything in GAE must be entirely Python.  So to remedy this, the GAE folks added an Images API.  This all makes perfect sense now, not sure why I didn’t see this immediately.

Anyway, problem solved.  The annoying bit here of course is that I wasn’t going to use PIL directly, but rather through the Django forms stuff.  Alas, that won’t work.  This is something I’m finding frustrating about GAE — namely, that I see cool stuff in Django and then can’t quite use it.  I guess that’s the price you (or I) pay for using GAE.  They can’t support everything, so I have to work within the supported subset.

Posted in Development.

Tagged with , , , .