One can install multiple python versions in unix based operating sytems such as Mac and Linux
To work on a specific python version one can simply use the commands - python'version' in the terminals
Examples:
python2.6 mycode.py would run python 2.6
python3 mycode.py would run python version3.*
Similarly for specific library installation using pip on can directly call
pip2.6 or pip-2.6 (respectively depending on using pip version 1.5 or lower)
The syntax for using easy_install is also similar:
sudo easy_install2.6 package
sudo easy_install package (would install the package for the default python)
Also to change the version of python one can simply create an alias for the command 'python' to the version of choice in the bashrc file
open the bashrc file with your favorite editor and place the following line in the end-
eg- vim ~/.bashrc
alias "python" "python'version' "
example: alias "python" "python2.6"
If you dont have a bashrc file in your home folder, create one and paste the code
Also never delete your original python in Linux/Mac OS because a lot of the OS software dependencies are linked to python and deleting can simply make your OS stop working
No comments:
Post a Comment