Here is an interesting post on how to install / manage different versions of Python in a single linux / ubuntu machine!
Pythonbrew is a magical tool. Which can also be called as Python version manager similar to that of RVM-Ruby version manager but Pythonbrew is inspired by Perlbrew.
Pythonbrew is a program to automate the building and installation of Python in the users $HOME.
Dependencies – curl
Before Installing the Pythonbrew, Install “curl” in the machine, to install curl use the below command in the terminal, give the the password for the user when prompted.
sudo apt-get install curl
After Installing the curl, Now Install Pythonbrew, copy and paste the following commands in the terminal and type the password for the user when prompted.
Recomended method of installation – Easy Install
sudo easy_install pythonbrew
To complete the installation, type the following command
Alternate method of installation:
Use curl command to download the latest version of pythonbrew from github.
curl -kLO http://github.com/utahta/pythonbrew/raw/master/pythonbrew-install
After downloading, change “pythonbrew-install” to “executable”
chmod +x pythonbrew-install
Then, run the pythonbrew-install in the terminal
Now the Pythonbrew has been installed in the “Home Directory” i.e., /home/user/.pythonbrew
Next, copy and paste the following line to the end of ~/.bashrc
*NOTE: change “user” to your user name in the system
Thats it! Close the terminal.
Steps to Install different versions of Python:
Open a new terminal, type the following command or copy and paste it.
pythonbrew install 2.6.6
This will install Python 2.6.6 and to install Python 2.7 or Python 3.2, change the version number in the previous command.
pythonbrew install 2.7
pythonbrew install 3.2
Update: If you get error while Installing then Install using the below command.
pythonbrew install --force 2.7
pythonbrew install --force 3.2
How to manage different versions of Python installed in system
For instance, if Python 2.6.6, Python 2.7 and Python 3.2 is installed in your system, switching between the versions can be done as follows:
By default, Python 2.6.6 will be active and in order to switch to Python 2.7 use the below command
pythonbrew switch 2.7
The default Python is changed to Python 2.7.
Now, to switch to Python 3.2 change the version number in the previous command.
pythonbrew switch 3.2
Use the below command to check or list the installed Python versions
Use the below command to check or list the available Python Versions to install
pythonbrew list -k
To uninstall any of the installed Python version (for example to uninstall Python 2.7), use the below command.
pythonbrew uninstall 2.7
Use the below command to update the Pythonbrew
Use the below command to disable the Pythonbrew and to activate the default version
Enjoy the experience of installing multiple versions of Python in single Linux / ubuntu machine!
Update: For Debian Users there is an alternative method in this site-http://www.stylesen.org/python_27_debian_squeeze_60