Which Python versions can be safely removed from Ubuntu 20.04?
I have the following versions of Python on my laptop running Ubuntu 20.04:
python2
python3.10
python3.9
python3-pasteurize
python2.7
python3.8
python3-config
python-argcomplete-check-easy-install-script
python3
python3.8-config
python3-futurize
python-argcomplete-tcsh
I know that Ubuntu relies on some of those, which ones can I safely remove?
EDIT:
As asked in the comments, here is the output of ls -l /usr/bin/python[23]* /usr/local/bin/python[23]*
:
ls: cannot access '/usr/local/bin/python[23]*': No such file or directory
lrwxrwxrwx 1 root root 9 Mar 13 2020 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 3674216 Mar 8 2021 /usr/bin/python2.7
lrwxrwxrwx 1 root root 9 Mar 12 2021 /usr/bin/python3 -> python3.8
-rwxr-xr-x 1 root root 5454136 Oct 5 00:09 /usr/bin/python3.10
-rwxr-xr-x 1 root root 5490488 Sep 28 18:10 /usr/bin/python3.8
lrwxrwxrwx 1 root root 33 Sep 28 18:10 /usr/bin/python3.8-config -> x86_64-linux-gnu-python3.8-config
-rwxr-xr-x 1 root root 5405872 Sep 10 01:20 /usr/bin/python3.9
lrwxrwxrwx 1 root root 16 Mar 13 2020 /usr/bin/python3-config -> python3.8-config
-rwxr-xr-x 1 root root 384 Mar 28 2020 /usr/bin/python3-futurize
-rwxr-xr-x 1 root root 388 Mar 28 2020 /usr/bin/python3-pasteurize
These 2 are important:
lrwxrwxrwx 1 root root 9 Mar 13 2020 /usr/bin/python2 -> python2.7
lrwxrwxrwx 1 root root 9 Mar 12 2021 /usr/bin/python3 -> python3.8
Anything started with python2 expects python 2.7 to be there. And the same goes for python3: it expects python3.8. To be on the safe side: keep python2.7 too; it might not be needed but removing it can break the system.
All others are manually added versions. Removing those will keep the system working but it will delete all software relates to it. So do inspect the packages when you do apt purge
or apt remove
. If you plan to delete 2.7 too do take extra attention on what the system will delete along with it.
The default Python version in Ubuntu 20.04 is Python 3.8. All other versions are something you installed yourself (or a dependency of something you installed).
So the system will only depend on 3.8, but other applications or projects you have may depend on the other versions (including Python 2/2.7).
You can also run apt rdepends --installed python3.9
to find out what packages depend on python3.9
.
Example output of apt rdepends --installed python3.8
as this is the version installed on my machine:
python3.8
Reverse Depends:
python3.8-minimal
python3.8-minimal
python3-uno
rhythmbox-plugins
python3.8-minimal
python3
python3-uno
xviewer-plugins