user713713
user713713

Reputation: 617

How to choose python version run when typing only "python" at prompt?

I have just installed Python2.6 on a Red Hat linux server which was supplied with python2.4 preinstaleld. When I type python, python2.4 is launched, typing python2.6 launches python 2.6 correctly. What is the correct way to make 2.6 the default? Also how can this result be possible:

$ python -V && which python && pwd && ./python -V
Python 2.4.3
/usr/local/bin/python
/usr/local/bin
Python 2.6.6

Upvotes: 1

Views: 7460

Answers (2)

vartec
vartec

Reputation: 134701

It's a symlink actually.

$ ls -al `which python`
lrwxrwxrwx 1 root root 9 2010-04-21 12:08 /usr/bin/python -> python2.6

So changing the default version from 2.4 to 2.6 would be just:

cd /usr/bin
sudo ln -sf `which python2.6` python

Upvotes: 5

jathanism
jathanism

Reputation: 33724

The easiest and quickest way, is to prepend the path to the 2.6.6 version to your PATH variable for your shell. This would go into your .bashrc or .profile, etc.

Assuming this path is /opt/foo/bin it would be:

export PATH=/opt/foo/bin:$PATH

If you don't include the possible side effects of things in the new path, this is the quick win.

This really depends on if you need this to be system-wide.

Upvotes: 3

Related Questions