Why isn't python 3 the default python binary?

I type python in a terminal window. I get Python 2.7 and not Python 3.5. According to the docs, Python 3.5 should come preloaded.


Solution 1:

I don't know what "docs" you are reading nor what they say, but the /usr/bin/python is just a symbolic link to the default version of python, in this case 2.7, which is the result of just typing python on the terminal. This is the result of PEP 394 which defines that

  • for the time being, all distributions should ensure that python refers to the same target as python2.

type python and file /usr/bin/python will confirm this.

The reason for this arrangement other than the convention, is that the source package python-defaults in Xenial is the version 2.7.11, so the python symbolic link points to this version.

To use python 3 you have to be explicit and type python3 in the command line, which is recommended in case you need an specific version, this can also be done with python 2, typing python2. Ubuntu includes both python 2 and 3 versions by default on all current versions.

There are plans to migrate everything to python 3 and marking it as the default.

Solution 2:

To get the Python 3.5 REPL or run a script that's compatible, type python3. This is to maintain compatibility with all the legacy python 2.x (which has always been, and will remain linked to python).

The dash could find python if you set up a .desktop file for it (in ~/.local/share/applications/), to open a terminal and start the REPL for instance. There isn't a default GUI REPL environment for python, and normal interface expectations are that the user would go to the terminal.

The talk of python 3.5 being default is the maintainers porting all system scripts from python 2.x over to python 3.x, not that python 3 would replace python 2 in all cases.