Score:1

Can Python 3.9 be safely removed from Ubuntu 22.04?

us flag

Can Python 3.9 be safely removed from Ubuntu 22.04?

I want to move to Python 3.10 and I am short on storage on my laptop, therefore I would like to delete Python 3.9 along with its libraries. I think the default Python version for Ubuntu 22.04 is Python 3.10 and they completely dropped support for Python 2. Does that mean that only Python 3.10 is required on my machine?

Here is the output of the command 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      10 Aug 18 12:39  /usr/bin/python3 -> python3.10
-rwxr-xr-x 1 root root 5917064 Aug 10 13:40  /usr/bin/python3.10
lrwxrwxrwx 1 root root      34 Aug 10 13:40  /usr/bin/python3.10-config -> x86_64-linux-gnu-python3.10-config
-rwxr-xr-x 1 root root 5299024 Sep  8 01:43  /usr/bin/python3.9
lrwxrwxrwx 1 root root      33 Sep  8 01:43  /usr/bin/python3.9-config -> x86_64-linux-gnu-python3.9-config
lrwxrwxrwx 1 root root      17 Aug 18 12:39  /usr/bin/python3-config -> python3.10-config
-rwxr-xr-x 1 root root     960 Dec 23  2020  /usr/bin/python3-futurize
-rwxr-xr-x 1 root root     964 Dec 23  2020  /usr/bin/python3-pasteurize
Score:2
cn flag

Let's figure out the answer:

On a 22.04 system....

$ apt-cache madison python3
   python3 | 3.10.6-1~22.04 | http://us.archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
   python3 | 3.10.4-0ubuntu2 | http://us.archive.ubuntu.com/ubuntu jammy/main amd64 Packages

There is the answer: The python3 provided in jammy/main is Python 3.10.x.

That's the required version of Python. Never change from 3.10.x while using 22.04.

  • You can remove Python 3.9. It might break some of your non-Ubuntu applications, but it won't break Ubuntu.

  • You can upgrade minor version bumps within 3.10.x. Example: From 3.10.4 to 3.10.6. The python3 version in jammy-updates will always be compatible, and that's what most users should stick with.

  • If you want to use other versions of Python, it's wise to put them in a virtual environment (venv) or container.

in flag
Sorry, but AFAIK the madison option just tabulates `apt-cache` output, and apt-cache just shows available packages not "required versions that can't be upgraded/removed" as you appear to suggest? Surely you want to look at rdepends for the python-3.9: `apt-cache rdepends --install python-3.9` (or whatever the package name is)?
user535733 avatar
cn flag
@pbhj the output in the answer (3.10) is what a stock install of Ubuntu 22.04 will include, and therefore the compatible version. Folks are completely welcome to parse out dependencies of Python 3.9 to see what removal will break. There are several ways of doing so, some tedious, some quick.
in flag
Got you user'33. Fwiw that command should be `apt-cache rdepends --installed python-3.9`, but it's specific to a package which has to be named in the command.
us flag
Thanks for the clear answer!
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.