Installing Python version manager for quick python version switch
Background
Often many Linux users having to either upgrade their current Python engine version or use another Python version in parallel to the current one that is in the system. However, many Linux users (n00bs and professional users alike) don’t know or cannot find sufficient documents online to show them the best way to do download and install another Python engine. In addition, many users may need to use a newer version of Python while still having the current Python version running on their Linux Operating Systems (OS). Therefore, the pythonbrew application can be downloaded and configured to help all users to download any version of Python they desire and providing them the ability to quickly switch from one Python version to another on the fly. Feel free to follow the next steps to learn how to do just that.
Operating systems:
The tool was installed and tested in the following Operating System (OS):
root@ubersec$ sudo lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 11.10
Release: 11.10
Codename: natty
Instructions
Open you terminal console and then switch user to root user by typing,
$su root
Now download python-setuptools by typing,
#apt-get -y install python-setuptools build-essential
Once you are done downloading python-setuptools, download the Python version manager by typing,
#easy_install pythonbrew
Once pythonbrew has been downloaded, type the following to complete he installation process,
#pythonbrew_install
Now you will need to add the following line source /home/user/.pythonbrew/etc/bashrc to the very end of your ~./bashrc file. For that purpose, please edit the file by using nano, vim, vi or gedit. For the purpose of this paper I have used the GNU editor.
#gedit ~/.bashrc
Now scroll all the way down and type (or copy and paste) the following line
source /home/user/.pythonbrew/etc/bashrc
Now exit and save the file and close out of your terminal windows. Now restarts you Linux OS by typing,
#shutdown –r now
Now open your terminal windows again and then logon as root once again. Then you are ready to use the pythonbrew command to download and install a new Python version. To do that, please type the following:
#pythonbrew install 2.7.2
That download and installation process should take for a while. However, if through that installation you receive an error message of any kind, please type the following and try that download and installation once again by forcing it,
#pythonbrew install --force 2.7.2
If everything has been installed as planned, type the following command to switch your python version,
#pythonbrew switch 2.7.2
In addition, you can keep downloading to your Linux OS as sorts of Python version and then switch in between each one of them as needed. If you want to see the current Python version that you have downloaded thus far, please type the following,
#pythonbrew list
If you want to see all available Python version that you can download with Pythonbrew, type the following command,
#pythonbrew list –k
To uninstall a Python that is already installed in your Linux OS use the following command,
#pythonbrew uninstall <version>
For example, to uninstall Python version 2.7.2 please type,
#pythonbrew uninstall 2.7.2
To update pythonbrew please type the following command,
#pythonbrew update
Use the below command to disable the Pythonbrew and to activate the default version of Python you Linux OS is currently use,
#pythonbrew off
You are done!