Tuesday, June 29, 2010

ImportError: No module named django

Have you ever installed appengine on a Mac, then installed django and then launched your app only to have appengine scream back at you "ImportError: No module named django"? Well suffer no more. Appengine for some reason expects django in the following folder:

/Library/Python/2.6/site-packages

Provided that your running Python 2.6, just place your un-tarballed django folder in that dir and appengine once again will be happy.

Now this might be confusing because if you just launch python, it will tell you its looking in another directory which might be true but is certainly not what appengine is doing.

>>> import os, django
>>> print os.path.dirname(django.__file__)
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django