1

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
1
  • 1
    depends on your distribution. please update your question with that information. Commented Apr 18, 2011 at 16:02

2 Answers 2

5

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
Sign up to request clarification or add additional context in comments.

3 Comments

This solves it, but I still don't get how the conflicting results from running python -V are possible.
./python runs it from the directory you're in, while python searches $PATH
He did run which to check what version was in PATH; however, which is an external command (try type which) and cannot see aliases. There was likely an alias, or python was hashed before a second copy was placed in /usr/local; hash -r flushes that.
3

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.