10

The scenario is: I am on Ubuntu 11 which comes with Python 2.7, I want to run Mozilla JetPack which supports Python 2.5/2.6 and Google App Engine which only supports Python 2.5.

Read that its not a good idea to remove Python 2.7 as Ubuntu maybe using it. So the correct way is to use virtualenv. But I am quite lost using it. I installed Python 2.5 in /usr/local/python25 following this guide

I tried

jiewmeng@JM:/usr/local/python25/bin$ ./python --version Python 2.5.5 jiewmeng@JM:/usr/local/python25/bin$ ./python virtualenv /works/tmp/test ./python: can't open file 'virtualenv': [Errno 2] No such file or directory 

then the below works but I will be using Python 2.7

jiewmeng@JM:/usr/local/python25/bin$ virtualenv /works/tmp/test New python executable in /works/tmp/test/bin/python Installing distribute.................................................................................................................................................................................done. jiewmeng@JM:/usr/local/python25/bin$ cd /works/tmp/test/bin jiewmeng@JM:/works/tmp/test/bin$ ls activate activate_this.py easy_install easy_install-2.7 pip python jiewmeng@JM:/works/tmp/test/bin$ ./python --version Python 2.7.1+ 

Also, how do I then run Mozilla JetPack or Google App Engine with this version of Python? Sorry I am new to Python (and Linux/Ubuntu)

2 Answers 2

15

Outline:

  • First cd to /usr/local/python25/bin
  • Download setuptools for Python2.5 (setuptools-0.6c11-py2.5.egg)
  • Install it (sh setuptools-0.6c11-py2.5.egg).
  • Now install pip (easy_install pip).
  • Install virtualenv and virtualenvwrapper using pip (pip install v... etc.).
  • Configure WORKON_HOME for virtualenv wrapper to work (export WORKON_HOME = $HOME/.virtualenvs). You can use any other directory you want (not just $HOME/.virtualenvs). Just make sure to use the full path.
  • Now create a virtualenv (mkvirtualenv foobar).
  • Switch to the new virtualenv (workon foobar).
  • Now install GAE, JetPack and whatever you want using pip install blah

Why did your install not work?

Looks like you did not install virtualenv for Python2.5. Hence this will not work.

jiewmeng@JM:/usr/local/python25/bin$ ./python virtualenv /works/tmp/test 

You can check by running ls command in that directory. I suspect you won't find virtualenv file there.

However this worked for you.

jiewmeng@JM:/usr/local/python25/bin$ virtualenv /works/tmp/test 

Because it is using the virtualenv file for system default Python2.7. You can check which virtualenv and opening the virtualenv script. You'll see that the #! will point to system default python.

So you need to install the easy_install and pip for Python 2.5 before you can create virtualenv for Python 2.5. Just follow the steps outlined above.

Sign up to request clarification or add additional context in comments.

3 Comments

did I just install setup tools to python 2.7? how can I install it for Python 2.5. Also do I need to reverse the changes or correct it? pastie.org/1826922
@jiewmeng Here are the first couple of lines from setuptools for 2.5 egg. #!/bin/sh if [ basename $0 = "setuptools-0.6c11-py2.5.egg" ] then exec python2.5 -c .... As you can see, it tries to python2.5 binary to install setuptools which should install to Python 2.5 folder. I suspect python 2.5 was not installed properly. Try typing python2.5 in bash and see if python 2.5 terminal opens. If it does not, then you'll need to install Python 2.5 and then run setuptools installation again.
whats the problem ... I tried to create a symlink but I get 2.7.1+ ... pastie.org/1827650. How do u install different versions of Python? I used this guide
2

You don't need to do anything fancy outside the virtualenv wrapper. Just use the --python=python2.5 flag (check out the man page for virtualenv form more). It does not matter what version you install it with, you just have to select the right executable for python in the virtual environment.

e.g. mkvirtualenv --python=python2.5 --distribute python25 if the python flag fails, either add a symlink (ln -s) to python25 in your $PATH or use the full path name on the python flag.

Also, default for multiple python installations is to have, for all 'altinstall' versions, a separate python and easy_install. So, for example: python2.5 ,easy_install-2.5 ,python2.6, easy_install-2.6 etc.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.