Why is Python 2.7 still the default Python version in Ubuntu?

According to official documentation of Python, Python2.7 support will end near in future.

DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support

Why is Ubuntu not using Python3 as default in their upcoming version?

$ cat /etc/os-release 
NAME="Ubuntu"
VERSION="19.04 (Disco Dingo)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 19.04"
VERSION_ID="19.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=disco
UBUNTU_CODENAME=disco
$ python
Python 2.7.16 (default, Apr  6 2019, 01:42:57) 
[GCC 8.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.

According to the release notes of Bionic Beaver:

Python 2 is no longer installed by default. Python 3 has been updated to 3.6. This is the last LTS release to include Python 2 in main.

And the above statement is true. Python 2 isn't installed by default in 18.04 and versions released after that. Ubuntu has already moved almost all of its projects from Python 2 to Python 3. For example, according to release notes of Disco Dingo:

Samba was updated to version 4.10.x, and one of the big changes here is python3 support. In Disco, samba and its dependencies are all python3 only now, with the exception of tdb. tdb still builds a python2 package, namely python-tdb, but all the others, including samba itself, are python3 only.

Moreover, even before the release of Ubuntu 18.04, Ubuntu/Canonical started asking developers to move to Python 3 because the end is near. From Python - Ubuntu Wiki:

All Ubuntu/Canonical driven development should be targeting Python 3 right now, and all new code should be Python 3-only. If you can't do this because of your dependency stack, let's talk.

It seems that on your system Python 2 was installed intentionally or may be as a dependency of some other package whose developer haven't moved to Python 3. You can check the packages you have installed which are dependent on Python 2 by running

apt rdepends python --installed

The reason why Python 2 is invoked when python is run lies in the one of the historical point of PEP 394 -- The "python" Command on Unix-Like Systems:

The python command should always invoke Python 2 (to prevent hard-to-diagnose errors when Python 2 code is run on Python 3).

On newer releases such as 20.04, Ubuntu provides two packages:

python-is-python2/focal,focal 2.7.17-4 all
  symlinks /usr/bin/python to the DEPRECATED python2

python-is-python3/focal,focal 3.8.2-4 all
  symlinks /usr/bin/python to python3

As the name suggests the earlier one would make python to invoke python2 and later will invoke python3. If you have no application which is dependent on Python 2, you can install python-is-python3 to make python to invoke python3. Alternatively, you can also edit the shebang of the script to /usr/bin/python3 to make script to directly use python3 as the interpreter.


To my knowledge, only arch linux did it: to call python3 from the default python command. Despite the PEP 394 recommendation.

It can be changed in /usr/bin by redefining the links between python, pythonX and pythonX.Y. But be prepared to cope with a lot of bugs, since all your all python2 scripts will mandate to have an explicit shell bang:

#!/usr/bin/env python2

A shell bang which is seldomly used in old scripts.