Change default Python version from 2.4 to 2.6

I want to use new software that requires Python 2.6 , and currently 2.4 and 2.6 tags are installed on our dedicated CentOS server, which look like this:

 $ which python /usr/local/bin/python $ which python2.6 /usr/bin/python2.6 $ which python2.4 /usr/local/bin/python2.4 $ ls -l /usr/local/bin/py* -rwxr-xr-x 1 root root 81 Aug 9 2007 /usr/local/bin/pydoc -rwxr-xr-x 2 root root 3394082 Aug 9 2007 /usr/local/bin/python -rwxr-xr-x 2 root root 3394082 Aug 9 2007 /usr/local/bin/python2.4 

How can I switch it to start using 2.6 by default python ?

+48
python linux version
Jul 26 '10 at 22:45
source share
6 answers

As root:

 ln -sf /usr/bin/python2.6 /usr/local/bin/python 

This will make a symlink from / usr / local / bin / python β†’ /usr/bin/python2.6 (replacing the old hard sheet).

+52
Jul 26 '10 at 22:52
source share

Alternatively, you can also add an alias for the python command to your bash shell startup file.

open the startup file: emacs ~ / .bashrc

in u append editor: alias "python" "python2.6"

and restart the shell.

+14
Aug 02 2018-11-11T00:
source share

rm /usr/local/bin/python
ln -s /usr/local/bin/python2.6 /usr/local/bin/python

+10
Jul 26 2018-10-22T00:
source share

In CentOS

 ln -sf /usr/local/bin/python2.6 /usr/local/bin/python ln -sf /usr/local/bin/python2.6 /usr/bin/python 

Check version:

 python -V 

Then, to fix yum "There is no module named yum", you should do:

 vi `which yum` 

and change #! / usr / bin / python to #! / usr / bin / python2.4

+2
Jul 28 '15 at 14:38
source share

I had a similar problem when using the meld command, I just renamed it to local, and it worked. Bad decision that I know, but I can always return it.

 sudo mv /usr/local/bin/python /usr/local/bin/re_python 
+1
Feb 06 '14 at 10:02
source share

Add an alias for the python command to your bash shell boot file. DO NOT change the symbolic link from / usr / bin / python, since changing the default Python (for example, in Ubuntu or Linux Mint) can disrupt your system

PS: read other answers

+1
Mar 20 '15 at 9:15
source share



All Articles