Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running multiple python version

I want to run multiple Python version in my box. Is there anything like version manager in Python where I can switch between multiple Python version without having to call the full path of the python binary? I have tried virtualenv and it seems to only cover problems running multiple python libraries version.

Thanks for your help.

like image 307
Joshua Partogi Avatar asked Oct 06 '10 21:10

Joshua Partogi


1 Answers

When calling python from bash you could try an alias.

user@machine:~$ alias python1234='/usr/bin/python2.5'
user@machine:~$ python1234
Python 2.5.4 (r254:67916, Jan 20 2010, 21:44:03) 
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

Let's say you have a script called script.py with following content:

import sys
print sys.version

So, launching a script with a different version of python looks like:

user@machine:~$ python script.py 
2.6.2 (release26-maint, Apr 19 2009, 01:56:41) 
[GCC 4.3.3]
user@machine:~$ python1234 script.py 
2.5.4 (r254:67916, Jan 20 2010, 21:44:03) 
[GCC 4.3.3]
like image 76
atomocopter Avatar answered Sep 28 '22 23:09

atomocopter