If you’ve been working on App Engine and you’ve noticed that some stuff works on your development server but not on your production, it may be related to the different versions of Python. Latest linux builds including Ubuntu 10.04 and 10.10 come with Python 2.6 pre-installed, but Google App Engine still runs Python 2.5 (an issue has been created to add Python 2.6 support, make sure you vote that up).
Their roadmap mentions nothing about upgrading. So in order to make your development server look more like your production servers, you’ll have to get Python 2.5, which is not that trivial at first.
So, Felix Krull has published an archive of new and old Python packages, so let’s use that source to get Python 2.5 running on a new Ubuntu box:
sudo add-apt-repository ppa:fkrull/deadsnakes sudo apt-get update sudo apt-get install python2.5
Yup, that was easy! Let’s now see if both Python 2.5 and Python 2.6 are available:
$ python2.5 Python 2.5.5 (r255:77872, Sep 14 2010, 15:51:01) $ python Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)
All done! Oh and don’t forget to launch your App Engine development server using python2.5 (installing it is not enough):
$ python2.5 dev_appserver.py .
As a bonus to this post, I’d like to share with you my way of working with App Engine, not in terms of code, but in terms of libraries organization. If you’re writing code for App Engine you’re probably working on more than one project at a time, hence you’ll need to use the SDK more than once.
So instead of copying it, replacing Python packages, etc, simply move the google_appengine folder to /usr/share and in every App Engine project create a symbolic link called .gae that points to that location. The SDK will automatically locate all the Google libraries and the development server is easy to launch:
$ ln -s /usr/share/google_appengine/ .gae $ python2.5 .gae/dev_appserver.py .
Don’t forget the dot at the end, since it tells the SDK which project to launch. And make sure you don’t push the .gae directory to your source control ;) Happy coding!
[…] This post was mentioned on Twitter by Konstantin Kovshenin and Python UK, Amor. Amor said: Installing Python 2.5 on Ubuntu Linux 10.10 http://bit.ly/i833Qt – via @kovshenin […]
I manually build and install it locally to ~/.local/ directories instead, as this is a per-user preference sometimes.
Yeah, might be a good idea too.
Works perfect. This was really helpfull, thank you.
sudo add-apt-repository ppa:fkrull/deadsnakes
This line fails with the error
gpg: requesting key DB82666C from hkp server keyserver.ubuntu.com
?: keyserver.ubuntu.com: Connection timed out
gpgkeys: HTTP fetch error 7: couldn't connect: Connection timed out
gpg: no valid OpenPGP data found.
gpg: Total number processed: 0
You should try the Ubuntu forums. I got it working yesterday.
Well I get the same problem.
If ist has been sorted out on the forum can you stale a URL?
"All done! Oh and don’t forget to launch your App Engine development server using python2.5 (installing it is not enough)"
You can still use virtualenv to make this part easier ;)
Good tip, thanks! :)
Thank You, Константин. I`ve put my ubuntu into the grave trying to install python2.5 for GAE. Next time i`ll hit my neck saying "Use Google, idiot!".
i`ll put "+" to your carma.
You're welcome sir! :)
Hi
Thanks for the tip. When I run dev_appserver with Python 2.5, I get a couple of warnings that do not come up if I run it with 2.6: 'No ssl package found…' and 'Could not initialize images API; you are likely missing the Python "PIL" module'
(Does that mean I need to use 2.6 to use PIL?)
Thanks for any thoughts
Dave, I bet you'll have to install PIL for Python 2.5. You can find more info here.
Hi,
I get this error –
Reading package lists… Done
W: GPG error: http://ppa.launchpad.net natty Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3B22AB97AF1CDFA9
when i run sudo apt-get update
Any suggestions?
Thank you
Are you using Ubuntu Linux 10.10?