How to run the other version of python I have installed on my Centos 5.3 [closed]

StackOverflow https://stackoverflow.com/questions/16074671

  •  04-04-2022
  •  | 
  •  

I have two different versions of python installed on my Centos 5.3 Final. The default version which is 2.4.3 and the new one which is 2.6.8.

[root@localhost bin]# ls py*
pydoc  pydoc26  pygtk-demo  python  python2  python2.4  python26  python2.6
[root@localhost bin]# python -V
Python 2.4.3
[root@localhost bin]# python26 -V
Python 2.6.8

I like to work with the new one but python still point to the old one.

[root@localhost Desktop]# python -V
Python 2.4.3
有帮助吗?

解决方案

try which python, and make your python to be linked to new 2.6.8.

其他提示

You can use the method mentioned by thkang, but what if you want to go back to python2.4.3 version? Solution is to use virtualenv, you can test your script or app with both versions.

The OS uses Python 2.4 likely. So you should not change it for root but if any scripts for root must use new version then use at top:

#/usr/bin/env python2.6

For a normal user you can make a link in ~/bin if that is in your path:

cd ~/bin
ln -s $(which python2.6) python

If ~/bin is not in your path add this to ~/.bashrc:

if [ -d ~/bin ] ; then
    PATH=~/bin:"${PATH}"
fi
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top