Please, open-up update-manager or Software Sources depending on your distro then add/tick universe repository from the software sources.
Read https://help.ubuntu.com/community/Repositories/Ubuntu "Adding Repositories in Ubuntu"
GUI-based repository management is normally accomplished via "Software
Sources". This interface can be accessed via several methods. For the
latest versions of Ubuntu, the easiest way is to go through the
"Ubuntu Software Center". Open the software center, then from the Edit
menu select "Software Sources". You will have to enter your password
to change settings in this window.
For older versions of ubuntu, there are several options:
Main Menu: System > Administration > Software Sources.
Synaptic : System > Administration > Synaptic Package Manager : >> Settings >> Repositories.
Main Menu: Ubuntu Software Center : >> Edit, Software Sources.
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.
Best Answer
No, it's not considered safe to define 2.7 as your default Python interpreter in Lucid. And I don't think it will be in the future.
There are no major version upgrades of any software in one release.
So python2.7 will not replace 2.6 as the default interpreter. This kind of upgrade is only done between versions, within one - especially an LTS - there are only so called stable release upgrades, i.e. bugfixes and security related upgrades.
However, it's perfectly safe to use python2.7, defining your interpreter as
#!/usr/bin/python2.7
and having users install it usingmake altinstall
on the python source, alongside python2.6