Newer versions of Ubuntu don’t come with Python 2.5 anymore however Google App Engine still requires (as of the date of this article) that you continue to use Python 2.5 for App Engine development. Some people have been using Python 2.6 but you need to be very careful. In the end for now it is safer to just use Python 2.5. Today I’ll go over what you need to do in order to get Python 2.5, the App Engine SDK, and Ubuntu 10.10 all working together and end it with a Hello World app.
Since the Python 2.5 bits are no longer in the Ubuntu repositories you need to grab them from here. You can do this easily from a terminal window:
$ sudo add-apt-repository ppa:fkrull/deadsnakes $ sudo apt-get update $ sudo apt-get install python2.5
Optional: Install the imaging tools:
$ sudo apt-get install python2.5-dev $ sudo apt-get install libjpeg62-dev $ sudo easy_install-2.5 pil
Run Python 2.5 to verify it’s working:
Type quit() to exit. Next, install the Python Setup Tools and grab the App Engine SDK (adjust the paths for newer versions of the Python App Engine SDK):
$ cd /tmp $ wget http://pypi.python.org/packages/2.5/s/setuptools/setuptools-0.6c11-py2.5.egg $ sudo sh setuptools-0.6c11-py2.5.egg $ cd $ wget wget http://googleappengine.googlecode.com/files/google_appengine_1.4.0.zip $ unzip google_appengine_1.4.0.zip
Let’s modify the .bashrc file now to make life easier when working with the SDK, for me this was:
$ cd $ sudo pico .bashrc
Append this to the file:
Mine looked like this:
Now we will modify the dev_appserver.py file located in the App Engine SDK folder. This ensures we will always use Python 2.5.
$ cd google_appengine $ sudo pico dev_appserver.py (you can use a different text editor if you wish)
Change the first line from:
Save and exit Pico after the change you just made.
Note: You might want to modify the other tool scripts to ensure they use Python 2.5 as well.
Let’s now create a Hello World app and see if everything works:
$ cd $ mkdir helloworld && cd helloworld $ pico helloworld.py
Add the following code to the helloworld.py file using Pico (or some other editor):
print 'Content-Type: text/plain' print '' print 'Hello World!'
Create the app.yaml file now:
$ pico app.yaml
The code for app.yaml:
application: helloworld version: 1 runtime: python api_version: 1 handlers: - url: /.* script: helloworld.py
Make sure we are in our home folder and run the app:
$ cd $ dev_appserver.py helloworld/ (the built-in app engine web server will now start, allow it to auto update if it asks you)
Browse to: http://localhost:8080
Thats all there is to it.