I have a long but not terribly recent history of trying Linux but never fully adopting it. As an exercise I wondered how feasible it would be to port my development environment for Python Google App Engine (GAE) to my new Ubuntu virtual machine. Most things on a Linux platform are possible as long as you know what you are doing, but I don't, so getting GAE running required some investigation.
Ubuntu - at least as installed by the my VMware Easy Install process - presented some challenges. Ubuntu no longer installs the correct version of Python, for example, nor does it install source headers for libraries some Python extensions required by the SDK need to compile. After discussing my problem on the Google App Engine forums I found two very helpful blog posts that present the two different approaches to setting up Google App Engine Python SDK under Ubuntu 10.01.
Both approaches achieve the same thing. The harder approach (well, longer) is to download the Python 2.5 and related sources and install them manually. The easier (and shorter) approach is to download the maintained Python 2.5 packages from a third party and use setup tools to do to the rest.
The following is my recipe which is mostly a tweaked version of the easier approach.
Ubuntu - at least as installed by the my VMware Easy Install process - presented some challenges. Ubuntu no longer installs the correct version of Python, for example, nor does it install source headers for libraries some Python extensions required by the SDK need to compile. After discussing my problem on the Google App Engine forums I found two very helpful blog posts that present the two different approaches to setting up Google App Engine Python SDK under Ubuntu 10.01.
Both approaches achieve the same thing. The harder approach (well, longer) is to download the Python 2.5 and related sources and install them manually. The easier (and shorter) approach is to download the maintained Python 2.5 packages from a third party and use setup tools to do to the rest.
The following is my recipe which is mostly a tweaked version of the easier approach.
- Create directory structure for Google App Engine SDK and Google App Engine projects. In the terminal:
cd ~
mkdir Projects
mkdir Projects/gae
(I am using exactly the same directory structure here as Boris does in his shorter approach. As mundane as it is I appreciate his detail here; As a Linux newbie I often wonder where to put things or even if it really matters)
- Download and extract the latest Google App Engine SDK for Python (currently at 1.3.8) to ~/Projects/gae/google_appengine
- Install Python 2.5. In this step I use the DeadSnakes repository for a maintained package of Python 2.5. I could also download the Python 2.5 source and compile it, but as wdenouden's Longer Approach shows you need to take care to already have SSL and Sqlite installed.
sudo add-apt-repository ppa:fkrull/deadsnakes
sudo apt-get update
sudo apt-get install python2.5
- Install Python Setuptools (ie easy-install) for Python 2.5
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
- (optional) if you need the GAE imaging API, you will need to install PIL. PIL needs to be compiled for the local system, so it needs both the Python 2.5 headers and the headers for the JPEG library installed on ubuntu:
sudo apt-get install python2.5-dev
sudo apt-get install libjpeg62-dev
sudo easy_install-2.5 pil
- Create a simple shell script to run the local development server and mark it executable by all. We'll put it firstly into the guestbook demo folder, test it and then copy it to the new_project_template.
cd ~/Projects/gae/google_appengine/demos/guestbook
echo "#!/bin/bash
python2.5 ~/Projects/gae/google_appengine/dev_appserver.py ./" > run
chmod a+x run
- Test the new file and our Google App Engine SDK install
./run
- Assuming all works well, copy the shell script to the new project template:
cp ./run /home/ben/Projects/gae/google_appengine/new_project_template/
Thanks Ben. I just started working with the image API and really needed this.
ReplyDeleteHi Erick, thanks for the feedback. Let me know if you experience any problems with the Imaging API from this configuration, since I couldn't test it when I came up with this recipe.
ReplyDeleteThank you, Ben. Here is how to install SSL support afterward (it's used by e.g. appcfg.py update):
ReplyDeleteapt-get install libssl-dev libbluetooth-dev
wget http://pypi.python.org/packages/source/s/ssl/ssl-1.15.tar.gz
tar xzf ssl-1.15.tar.gz
cd ssl-1.15/
python2.5 setup.py install
Hi Onestone, thanks for the tip regarding SSL. I noticed while investigating that I didn't need to do this for dev_appserver.py to work when I used the Deadsnakes PPA (as opposed to compiling 2.5 from sources). I guess I might still need this for appcfg.py.
ReplyDeleteGreat Work :-)
ReplyDeleteThank You really a life saver....
Thanks for the post but I'm still having a few issues. :-(
ReplyDeleteFirstly 10.10 comes with Python 2.6 and 2.7. Does Google Apps engine only work with 2.5 i.e it does not work with 2.6 or 2.7??
'm asking this because after following you instructions it fails with errors. The code under point 6, should that all be on one line?
Hi JJ
ReplyDeleteGoogle App Engine absolutely requires Python 2.5, so you need to install it alongside 2.7.
Yes, I can see how instruction 6 could be confusing. It is all entered in at the command line, and the line beginning with "echo" ends with the redirection "> run". All other commands are separate.
Hope that helps!
Thanks Ben. All a bit confusing but I installed 2.5 like you mentioned and got it to work. I could not create the script with echo and could not get it to work so I just edited /google_appengine/dev_appserver.py and /google_appengine/appcfg.py so that the first lines to look like: #!/usr/bin/env python2.5
ReplyDeleteAll good now.
Thanks, Thanks, Ben!
ReplyDeleteMay I use your guide to create a video to help developers interested in coding for the Khan Academy with setting up their development environment? I will give you attribution in the video :]
ReplyDeleteMichael
Sure thing Mike, no problem.
ReplyDeleteThanks!
ReplyDeleteThere's an up to date post here - http://terse-words.blogspot.co.uk/2012/05/install-google-app-engine-on-ubuntu.html
ReplyDeleteexactly what i was looking for, thanks a ton ben!!!!
ReplyDelete