How can I install Python's latest version on Ubuntu 20.04 and make sure that it's set as the default Python version for all users on the system?

vi flag

I'm working on an Ubuntu 20.04 machine and need to ensure that I have the latest version of Python installed. How can I install it and make sure that it's set as the default Python version for all users on the system?

I've tried using the package manager to install Python, but it only installs an older version. I've also tried compiling from source, but that doesn't seem to work either.

Any help would be greatly appreciated. Thanks!

David avatar
cn flag
If you install any version of Python that is not the one the OS came with you will no longer have a working OS. Ubuntu needs the version it ships with for its own functions. What you can do is research and install multiple versions of Python with out changing the default.
us flag
Does this answer your question? [Installing python: who is deadsnakes and why should I trust them?]( Follow the answer, and replace python3.9 with python3.11.
ec flag

First of all: NEVER change the default version of Python that ships with the Ubuntu release. Parts of the system rely on this specific Python version. Changing the version may result in all types of errors up to a not anymore working Ubuntu installation.

However, it is very easy to install multiple Python major release parallel without conflicting each other. They just have to be called by stating the specific version, e.g. python3.11 for Python 3.11.

This can be achieved by compiling and installing Python yourself. The process is pretty easy and straight forward.

A step-by-step instruction can be found at Link

The really important step in the process is to use sudo make altinstall after running .\configure, as altinstall ensure that the default Python version is not overwritten.


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.