Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I configure multiple Ubuntu Python installations to avoid App Engine's SSL error?

I have Karmic Koala which has Python 2.6 installed by default.

However I can't run any Python App Engine projects because they require Python 2.5 and python ssl.

To install ssl I installed python2.5-dev first while following some instructions I found elsewhere.

sudo apt-get install libssl-dev
sudo apt-get install python-setuptools
sudo apt-get install python2.5-dev 
sudo easy_install-2.5 pyopenssl

However, I am afraid this is not good for my Ubuntu installation since Ubuntu expects to see version 2.6 of Python when you type 'python' on the command line. Instead, it says '2.5.5'.

But App Engine still doesn't work after all this. I continue to get an SSL-related error whenever I try to run my Python app:

AttributeError: 'module' object has no attribute 'HTTPSHandler'

UPDATE1: Just checked whether SSL actually installed as a result of those commands by typing this:

$ python2.5
Python 2.5.5 (r255:77872, Apr 29 2010, 23:59:20) 
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named ssl
>>> 

As you can see, SSL is still not installed, which explains the continuing App Engine error.

UPDATE2:

I tried to revert to the original default version of Python by doing this:

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

in my /usr/bin/local folder.

Now I get Python 2.6.4 when I type 'python' on the command line.

But this doesn't solve my App Engine SSL issue.

If anyone knows how I can dig myself out of this hole, I would appreciate it.

like image 741
Linc Avatar asked May 01 '10 05:05

Linc


2 Answers

You should be able to simply install Ubuntu's standard copy of Python 2.5. The SSL module isn't a requirement - as the warning message says, it's necessary if you want to do certificate validation, but that's all.

The error you're getting with a missing 'HTTPSHandler' is probably due to installing a version of Python that was compiled without SSL support (this is independent of the ssl module, which is what does certificate validation) - again, try installing the standard version.

As far as version selection goes, installing Python 2.5 shouldn't intefere with the default system version - there's a selector tool for choosing which version is the default - so you can simply run the dev_appserver etc with 'python2.5 dev_appserver.py'.

like image 65
Nick Johnson Avatar answered Sep 30 '22 11:09

Nick Johnson


On Ubuntu 9.10, a simple sudo aptitude install python2.5 should do the trick, then just call the scripts by prepending python2.5, like this:

python2.5 google_appengine/dev_appserver.py ...

On Ubuntu 10.04 however, this is a whole lot different since Python 2.5 is not in the repositories anymore... This means installing from source, and from having had to do it, I can tell you it's not funny. It just makes you wish Google would move on issue 757.

Installing the SSL support for Python 2.5 is the same, whether installed from the repos or compiled from source. Just download the SSL lib for 2.5, un-package it, and run

sudo python2.5 setup.py install

Edit: Comment 51 of previously cited issue explains in detail how to install Python 2.5 on Ubuntu 10.04. As you can see, this is really cumbersome!

like image 42
Emilien Avatar answered Sep 30 '22 12:09

Emilien