Running Google App Engine against Python 2.5 on Mac OSX 10.6 Snow Leopard

Monday, 15 March 2010 03:01

I ran into a strange error yesterday night while working on an App Engine project in Python. Most of the application worked perfectly, but certain views threw errors like the following:

ImportError: No module named _ctypes

However, the same application worked perfectly on my Windows 7 development server.

I was puzzled for a while, but it turns out that App Engine currently only supports Python 2.5.x, while in Snow Leopard the default Python version was updated to 2.6.1.

Python 2.5 is still installed on Snow Leopard, so it's just a case of explicitly pointing the App Engine development server at the correct version. If you're using the Google App Engine Launcher, open the Preferences dialog, and enter the following into the Python Path field:

/usr/local/bin/python

Edit: as Ruchi points out in the comments, make sure you press Enter after inputting the path or the change will not take effect.

The development server will now run your apps against the correct (supported) version of Python and the errors should disappear.

Comments

Ruchi 06/08/2010 10:18

Thanks! I've been looking everywhere and your post helped me. Just one more thing - we need to press Enter after giving the path in GAE. It doesn't work otherwise. Thanks again!

dosa 29/08/2010 08:18

Thanks -very useful, but for me the path is /usr/bin/python2.5

Ash 24/09/2011 10:57

I found this on the Mac OS X python man page ...

You can set the default python version that Mac OS X uses via the following command:

defaults write com.apple.versioner.python Version 2.5

Steve Trefethen 20/11/2011 07:20

Thanks, I totally missed that!

Add your comment