How-To

Installation of Python 2.5 and Google App Engine in Ubuntu 11.04

If you are planning run Google App Engine Server inside your Ubuntu, It can be a lot of pain in the ass. After tons of searches on Stack Overflow, I didn’t get the proper solution which I wanted. There are different ways to install App Engine Server in your Ubuntu Machine. But most important part is installation of Python 2.5 in the machine and that is the most intricate part. Now I will show you why you need Python 2.5, how to install it and so on….

STEP 1: (Python 2.5 Installation)

Even before starting your App Engine Server there is one important dependency you need to look. i.e. Python 2.5. Google App Engine SDK is compatible with Python 2.5 only. However Ubuntu 11.04 comes with Python 2.7, if you have tried then you will find that Server can run under Python 2.7 environment too. But as the project becomes more complex you will need Python 2.5 otherwise for ‘Hello World’ projects it’s not necessary to have Python 2.5 (according to my experience).

If you are planning to do some ‘sudo apt-get install python2.5’, It won’t work. As Python 2.5 is not present in the latest Ubuntu Repos. It has been removed after release of Ubuntu 9.10.

You can install Python 2.5 by downloading the source code from its website but it does not work for App Engine even though Python 2.5 is present in your machine it will give you error about AttributeError: ‘module’ object has no attribute ‘HTTPSHandler’ . So better solution for that is given by a guy called Felix Krull. He has published newer and older versions of python as PPA. Trust me at one point even I refused to install Thrid Party PPA but I had no other choice. Here are some commands:

sudo add-apt-repository ppa:fkrull/deadsnakes

sudo apt-get update

sudo apt-get install python2.5

Thats it! Now you have Python 2.5 in your machine. You can check it out by running:

python2.5

But however your default python is still python2.7 (run python -V). (If not then read Step 2)

[EDIT] In my earlier post following method was used to replace default python with python2.5 as AppEngine needs Python2.5 as I mentioned earlier. But this may further lead to Broken Applications, ie applications like Software Center, Gwibber, Unity Dash which are dependent on Python2.7 will not work as you have replaced default python with 2.5. So you are supposed to move directly to ‘installation of Google App Engine Step’. However if you want to play with Ubuntu you can view it.

You need to replace that with python2.5. It can be done by creating a new Symbolic Link:

sudo rm /usr/bin/python

sudo ln -s /usr/bin/python2.5 /usr/bin/python

Now you have python2.5 as default python. (Confirm it by python -V)

STEP 2: (Installation of Google App Engine)

This one is the most simplest thing. All you need to do is Download Google Appengine Python SDK extract it where ever you want you will get a directory called ‘google_appengine’. Get the path for ‘google_appengine’ and then run:

$ [path will be here]/google_appengine/dev_appserver.py

You should get a list of all ‘Options’ if you are getting it means App Engine is successfully installed.

Now let us move back to ‘Python2.5’. Even though Python2.5 is installed in your machine AppEngine is not actually using it. As it uses default Python (ie 2.7 in this case). If you are creating simple applications e.g. ‘Hello World’ then App Engine will work but as your application becomes complex App Engine will break as it does not support Python2.7. So to use Python2.5 by AppEngine you have to open dev_appserver.py file in any Editor which will have first line as #!/usr/bin/env python all you have to do is replace it with #!/usr/bin/env python2.5. This will tell AppEngine to use python2.5 as startup environment.

However you will be working with more projects so everytime running

$ [path will be here]/google_appengine/dev_appserver.py [path for the project]

will be time-consuming so this problem can be solved by setting up environment variables.

In this case you need to edit .bashrc file present inside Home Directory (It will be hidden). Run

$vim .bashrc

or

gedit .bashrc

And at the end put ‘export PATH=$PATH:[Your path to]/google_appengine/’. Save it and then confirm it by running ‘echo $PATH’ if you get ‘google_appengine’ path in the end means it has been successfully done. Now instead of running

$ [path will be here]/google_appengine/dev_appserver.py [path for the project]

all you have to do is run :

$ dev_appserver.py [path for the project]
Standard

20 thoughts on “Installation of Python 2.5 and Google App Engine in Ubuntu 11.04

  1. Anonymous says:

    I have setup GAE under Ubuntu 11.04 without any problems using your approach.Thank you, it was very helpful post.

  2. Luis says:

    I have had some problems with administrative tasks by replacing the /usr/bin/python link. I saw in another webpage another approach for it ;What you can do, is edit the dev_appserver.py file and replace first line by#!/usr/bin/python2.5so, google app engine will use python, but all the rest ubuntu applications will still be using python 2.7 as desired.regardsLuis

  3. Anonymous says:

    thanks man.. have u encountered any problems with other applications running on 11.04 because of the python version change..

  4. Anonymous says:

    I’m sorry to post it late. Actually Thank You @Fabio to reminding me. I should have edited this post earlier but I forgot to edit it. Anyways here is the solution for that. I have added a step to put Symbolic Link to Python2.5 in Step1.2 which is not required in fact it is fatal. By changing Default version of python from 2.7/3.0 to 2.5 you are makin other applications vulnerable as they work on either 2.7 or 3.0. Such applications include- Unity Dash, Software Center, Gwibber etc. So all you have to do is open to ‘google_appengine/dev_appserver.py’ and replace 1st line which must be *#!/usr/bin/env python* with *#!/usr/bin/env python2.5* now this line depicts which env should Python use. I came to know about it when I was doing basics of Python (Again :p)You can view this thread on http://askubuntu.com/questions/45159/problem-with-python-2-5-in-ubuntu-11-04

  5. Anonymous says:

    no worries.. i had tried using the symbolic link and realised that the software center wasn't workin.. <br>i simply deleted the old link file and created a new one pointing to 2.7<br>thanks anyway i learnt something new about ubuntu 🙂

  6. Anonymous says:

    Note my statement- You will find Appenine working in python2.7 but this is not the case. When you create huge n intricate applications which has enormous kinds/database and ur app becomes relatively big then in that case AppEngine will break. You need to change it to python2.5 for safer side.

  7. Richard says:

    Hehe, just thought that it was a pot of luck that I came across this post as google’s documentation on pubsubhubbub really sucks. If it wasn’t for this post I wouldn’t even be able to get the examples going as the repo on svn for pubhubsubbub does not work. Had to download a previos version of main.py for the hub to work and then python 2.7 would not fire the google app_engine and then the tubes example would not run as there was an error in one of the python files to include simplejason. After reading this page it all started falling into place. So thanks a million for this post guys 🙂

  8. saju says:

    getting message unable to connect while open http://localhost:8080/test@saju-laptop:~/Desktop/google_app_engine$ python2.5 google_appengine/dev_appserver.py helloworld/WARNING 2011-09-19 19:06:57,148 urlfetch_stub.py:108] No ssl package found. urlfetch will not be able to validate SSL certificates.INFO 2011-09-19 19:06:57,372 appengine_rpc.py:159] Server: appengine.google.comWARNING 2011-09-19 19:06:57,375 datastore_file_stub.py:512] Could not read datastore data from /tmp/dev_appserver.datastoreINFO 2011-09-19 19:06:57,376 rdbms_sqlite.py:58] Connecting to SQLite database ” with file ‘/tmp/dev_appserver.rdbms’WARNING 2011-09-19 19:06:57,377 dev_appserver.py:4748] Could not initialize images API; you are likely missing the Python "PIL" module. ImportError: No module named _imagingINFO 2011-09-19 19:06:57,381 dev_appserver_multiprocess.py:637] Running application helloworld on port 8080: http://localhost:8080

  9. Gabriel I. Csanalosi says:

    So I’m running Ubuntu Chroot 11.04 on my HP Touchpad. After making an install for python 2.5.6 (I couldn’t find a build for the ARM processors) and then following all the instructions afterwards, I still got errors from dev_appserver.py saying that I was still running 2.7 runtime instead of 2.5. I checked in my /usr/sbin/ folder and found that "python" and "python2.7" exist, but no python2.5. However, if I type "python" at the command line, python 2.5 starts up. I tried the combinations, "usr/bin/env python", "usr/bin/env python2.5", "usr/bin/python" and don’t know what else to try. Any suggestions?

  10. dewbot says:

    try executing ‘python2.5’ in command line which will take you to Python 2.5 prompt if you get any error like ‘command not found’ then its not installed properly (which I don’t think you will get)If there are no errors then execute ‘which python2.5’ this will return a dir where ‘python2.5’ is installed then simply replace that string with ‘/usr/bin/python’ in dev_appserver.py so that by default dev_appserver.py will be executed python2.5 rather than 2.7.Even if you are getting ‘Warnings’ (not errors) about python2.7 its not a big issue if you are dealing with large scale application. Anyways nice to see some one is trying tweaks with Touchpad. How it is in performance n all?

Leave a reply to Gabriel I. Csanalosi Cancel reply