Total Pageviews

Donate

Dec 15, 2010

Changing default python version in Ubuntu

It happens a lot that you have installed more than one version of python on Ubuntu. let's say python2.5 and python2.6 and you want to change the default python version.

It is very simple and with a single line of shell script


For example if I have python2.6 is the default and I wanna to change it to python2.5
Here is the default python when you just type python in the command

~$ python
Python 2.6.2 (release26-maint, Apr 19 2009, 01:58:18)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>


Now let's change it

~$ sudo rm /usr/bin/python && sudo ln -s python2.5 /usr/bin/python
Now check the verstion

~$ python
Python 2.5.4 (r254:67916, Jan 20 2010, 21:45:54)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
and also to change it back use the same command again

~$ sudo rm /usr/bin/python && sudo ln -s python2.6 /usr/bin/python
How this works??
1) we remove the executable from /usr/bin/python
2)we link (ln) the python version we want to be copied again to the location of python executable

Very simple :)
Hope it is useful :)

3 comments:

  1. thanks a lot we faced this kind of problems when installing some application on Ubutu

    ReplyDelete
  2. Any time Mr. Raed :)
    I hope my blog posts always be helpful for you :)

    ReplyDelete
  3. I have followed this technique to downgrade from version 2.6 to 2.5, it worked but some applications stopped working any idea how to fix this??

    ReplyDelete

Donate