Sunday, October 9, 2011

Prepare Ubuntu 11.04 For Google AppEngine Development

1) Install Python 2.5
The AppEngine SDK requires Python 2.5 but sadly Ubuntu 11.04 has 2.7.1 installed by default. The easiest way to get Python 2.5 installed on your machine is to do the following.

  • Open a terminal and and type the following commands.
    sudo add-apt-repository ppa:fkrull/deadsnakes sudo apt-get update
    sudo apt-get install python2.5 


2) Install AppEngine SDK

  • Download the current version of the AppEngine Python SDK (1.5.4)
  • Extract the archive to your desired location. I just installed extracted the archive to my $HOME directory.
3) Edit the SDK Scripts
Unfortunately, since the SDK will only work for Python 2.5 we need to edit each of the SDK scripts to ensure that Python 2.5 is used when running the scripts. Remember, the default version of Python on Ubuntu 11.04 is 2.7.1. If we don't edit the scripts to use Python 2.5 the scripts will be run using the default Python interpreter.
  • Open each of the following files.
    • /$HOME/google_appengine/appcfg.py
    • /$HOME/google_appengine/bulkload_client.py
    • /$HOME/google_appengine/bulkloader.py
    • /$HOME/google_appengine/dev_appserver.py
    • /$HOME/google_appengine/gen_protorpc.py
    • /$HOME/google_appengine/remote_api_shell.py
  • Replace the first line of each of the files that reads #!/usr/bin/env python with one that reads #!/usr/bin/env python2.5


4) Add SDK To The $Path Environment Variable
You want to add the SDK directory to the $PATH environment variable to make executing the SDK scripts much easier. As opposed to having to type in the full path of the SDK script, $HOME/google_appengine/dev_appserver.py, you will only have to type dev_appserver.py.

  • Open your $HOME/.bashrc file and scroll to the very bottom.
  • Add the following lines of code
    # set PATH so it includes the Google AppEngine SDK
    if [ -d "$HOME/google_appengine" ] ; then
    PATH="$HOME/google_appengine:$PATH"
    fi
That's pretty much it.