python-is-python3 package in Ubuntu 20.04 - what is it and what does it actually do?
In Ubuntu, all python packages use explicit python3 or python2 interpreter and do not use unversioned /usr/bin/python
at all. Some third-party code is now predominantly python3 based, yet may use /usr/bin/python
.
python-is-python3 is a convenience package which ships a symlink to point the /usr/bin/python
interpreter at the current default python3. It may improve compatibility with other modern systems, while breaking some obsolete or third-party software.
python-is-python3 replaces: python, python-is-python2.
I installed python-is-python3 as a convenience package in Ubuntu 20.04, but I later uninstalled it after python2.7 was automatically installed as a dependency of another package.
As the package description you linked to says:
In Ubuntu, all python packages use explicit python3 or python2 interpreter and do not use unversioned /usr/bin/python at all ... No packages may declare dependencies on this package.
So, all official Ubuntu packages will depend explicitly on "python2" or "python3", and invoke the appropriate command. The default "python" command is deliberately undefined so that any scripts referencing it have to be updated to unambiguously depend on one version or the other.
However, users may have code that relies on the "python" command being available, and know that they can safely point it across their whole system to one version or the other. The python-is-python3
package (and its counterpart, python-is-python2
) are a convenient way to set up a symlink for this purpose.
Does python-is-python3 really just create a single symlink? It seems odd to introduce a package for such a bare bones purpose.
Linux distributions are extremely complex systems made up of a large number of simple components. The power of package managers comes in their flexibility to do simple things like this in a unified way. For instance, a server setup script might have a long list of apt
packages that an application needs to be installed, and can simply include python-is-python3
in that list. Shipping a package for this purpose is considerably simpler than having a user guide explaining how to manage the symlink manually.
Does the same go for
pip
, i.e.pip
instead ofpip3
?
Apparently not - according to this LaunchPad bug, the python3
package automatically points pip
at pip3
anyway.
If you open up the .deb
file for the package (I used 7-Zip), you can see that apart from some documentation, it really does just contain one symlink, to be installed at /usr/bin/python
, pointing to /usr/bin/python3
.