How to install Python 3.11 on Ubuntu 22.04

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

Hello, friends. If you are a Python developer, then you know that it pays to have recent versions to take full advantage of the language. Today, you will learn how to install Python 3.11 on Ubuntu 22.04. In addition to this, you will be able to set one as the default on the system.

One of the most anticipated features of this version is that according to the release, Python 3.11 is between 10-60% faster than Python 3.10. On average, we measured a 1.25x speedup on the standard benchmark suite.

Thanks to this then, it can be said that Python has improved a lot, and it will be noticed in more robust applications and in less advanced systems.

In each release, there are many changes to note, some of them are:

  • Update bundled libexpat to 2.5.0
  • Fix multiple crashes in debug mode when str subclasses are used instead of str itself.
  • Update the bundled copy of pip to version 22.3.1.
  • Fix memory leak in math.dist() when both points don’t have the same dimension.
  • Fine-grained error locations in tracebacks

And so many more.

Install Python 3.11 on Ubuntu 22.04

To install this new version of Python, the best and easiest thing to do is to add an external PPA.

So, open a terminal and update the system

sudo apt update
sudo apt upgrade

Then, add the Python 3.11 PPA to the system

sudo add-apt-repository ppa:deadsnakes/ppa

Then refresh APT

sudo apt update

Finally, install Python 3.11 with some of these commands

sudo apt install python3.11
Install Python 3.11 on Ubuntu 22.04
Install Python 3.11 on Ubuntu 22.04

Or

sudo apt install python3.11-full

The difference is that with the second one, you will be able to install PIP and other libraries.

Then, verify the installed version with the following command

python3.11 --version

Sample Output

Python 3.11.0

How to set Python 3.11 as the default

Occasionally you may want to change the version of Python that the system will take by default. Although it can be risky, I’ll explain how to do it.

First, set a symbolic link from the current version of Python to update-alternatives.

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 110

Then do the same with the 3.11 version we just installed

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 110

Now yes, choose the Python version by running

sudo update-alternatives --config python3
Python 3.11 on UBuntu
Python 3.11 on UBuntu

Select the one you like best, and you’re done.

Conclusion

In this post, you learned how to install Python 3.11 on Ubuntu 22.04. As you can see, the process is simple and anyone can do it.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
Angelo
Angelo
I am Angelo. A systems engineer passionate about Linux and all open-source software. Although here I'm just another member of the family.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook