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:
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.