Starting with SDK 1.6.0 the App Engine fully supports Python 2.7. This article originally described a workaround for getting Python 2.7 running on SDK 1.5.5. Now it only describes how to port your
app.yaml and request handlers to Python 2.7.
The following instructions work with any WSGI-compliant web framework. I'll explain how to use Python 2.7 with djangoappengine/Django-nonrel at the end of this post. Yes, Django-nonrel works with Python 2.7 on App Engine. This blog (All Buttons Pressed) is already running on Python 2.7 with
Let's start with a simple
app.yaml for Python 2.5:
handler.py file looks like this:
In order to use Python 2.7 you have to change your
app.yaml like this:
Here we've changed the runtime to
threadsafe: yes and modified the last line (
script) to point to the WSGI handler directly instead of just the
handler.py can be simplified like this:
In other words, we've just removed
main(). Note, webapp users would normally port their code to webapp2, but that's not really relevant for this post, so let's just ignore that detail.
That's all you need to use Python 2.7 on both the production server and dev_appserver.
Using djangoappengine with Python 2.7
If you're a Django-nonrel / djangoappengine user you can just change your
app.yaml to look like this:
That's it. djangoappengine will take care of the rest. Note that the
libraries section is currently necessary due to a bug in SDK 1.6.0. Since you're already deploying a custom
django package it shouldn't be necessary to enable Django in the
libraries section. The App Engine team will fix this bug in the next SDK release.