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.
Best Answer
According to the release notes of Bionic Beaver:
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:
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:
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
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:On newer releases such as 20.04, Ubuntu provides two packages:
As the name suggests the earlier one would make
python
to invokepython2
and later will invokepython3
. If you have no application which is dependent on Python 2, you can installpython-is-python3
to makepython
to invokepython3
. Alternatively, you can also edit the shebang of the script to/usr/bin/python3
to make script to directly usepython3
as the interpreter.