Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Possible Duplicate:
How do I make the terminal run python 3.1?

I am using Ubuntu 10.10 and just installed Python 3.1 but entering python on my Gnome Terminal gets me Python 2.6 . How to fix it to get Python 3.1 on typing python on the terminal ?

share|improve this question
add comment

marked as duplicate by Takkat, Jorge Castro, Oli Apr 7 '11 at 16:04

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers

up vote 6 down vote accepted

I can't sanction Dayjay's answer at all. Replacing Python system-wide could make applications hugely unstable and in a lot of cases, they'll just break.

  • Python-based libraries are installed to a version-specific place (eg /usr/lib/python2.6/) so swapping in a new version without catering for existing packages will break things that need things on the right Python path.

  • There are major language differences between 2.6 and 3.x that, if a package doesn't check to see what version it's using (common of older scripts) could make things unstable.

    For example, if you divide two ints in 2.6 you are returned a floored int; but in 3.x it'll return a float.

The safest thing to do is just call the 3.x binary when you want to use Python 3.x.

python3.1 my_python_script.py
share|improve this answer
    
You are right , but his answer is probably ok for my specific scenario which is a lot less critical then you might suspect. I have just installed a Ubuntu guest OS on a virtual box (hosted by Windows 7 ) at my home PC. The whole point is to play around with the distro including the use of Gnome terminal and Python 3 in Linux. It does not matter even if the whole system is screwed... its used as a toy anyway. I did use the python3.1 command on the shell , and it worked well ... but was a little inconvenient. So I wanted to just use the python command for the 3.1 version. –  explorest Apr 7 '11 at 12:34
    
By the way, if it were a critical situation, then what would you suggest to reverse what I did by changing the symlink. Simply execute the inverse commands and restore the symlink to Python 2.6 ? –  explorest Apr 7 '11 at 12:36
    
Yeah, just delete the symlink again and make a new one back to /usr/bin/python2.6 –  Oli Apr 7 '11 at 12:58
    
One funny thing (probably a major system screw up) that I noticed after the original redirection of the link to Python 3.1 was that the Ubuntu Software Center wont start on clicking..... it just wont , even after reinstalling the Ubuntu Softwar Center. Now when I reversed the default version to Python 2.6 ... it started to work again ... lolz ... yeah that was fun !! –  explorest Apr 7 '11 at 19:59
add comment

You could simply change the symlink:

rm /usr/bin/python
ln -s /usr/bin/python3.1 /usr/bin/python
share|improve this answer
    
I don't know why this answer is getting downvoted. He wanted to run python 3.1 if he types python (for any reasons), thats exactly what it does. –  Dayjay Apr 8 '11 at 6:09
    
I wouldn't say that changing the symlink is a security concern, but editing system files (including symlinks to system files) without understanding exactly what they do and why they do it that way can expose a user to a lot of problems that they might not be able to solve. –  Tyler K. Apr 10 '11 at 2:39
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.