Ubuntu – How to default to newest version of Python?

default-programsgnome-terminalpython

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 ?

Best Answer

  • 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