How to install Python 3.11 on Ubuntu 20.04

In this tutorial guide, I will take you through the installation steps for the new Python 3.11 release on an Ubuntu 20.04 distro.

Python programming language is an interpreted high-level general-purpose programming language. Its design philosophy emphasizes code readability with its use of significant code indentation.

We can begin by installing a python 3 interpreter on our system. This is a program that reads Python programs and carries out their instructions, you need it before you can begin python programming.

Python 3.11 new Features

  • Introduction of enhanced error locations in tracebacks. Whenever you are printing tracebacks, the intepreter will now point to the exact expressions that caused the error instead of just the line. Traceback is a report containing the function calls made in your code at a specific point. When your program results in exception, Python will print the current traceback to help you know what went wrong. In Python it is best to read traceback from bottom up. This is very helpful if since the traceback is printed out and your terminal usually ends up at the bottom of the output, giving you the perfect place to start reading the traceback.
  • The introduction of column information for code objects. The information used by enhanced traceback feature is made available as a general API taht can be used to corelate byte code inmstaructions with source code. code objects are a low level detail of the CPython implementation.

Related Articles


  • Make sure you are running Ubuntu 20.04 distro
  • Have a user with sudo privileges
  • Make sure you have basic understanding of terminal

Table of Contents

  1. Update your Ubuntu 20.04 repositories
  2. Install deadsnake PPAs
  3. Install software dependencies
  4. Install Python 3.11
  5. Conclusion

1. Update Ubuntu 20.04 repositories

The first thing we need to do for our freshly installed system is to update repositories to reflect current changes going on within the system. Use the following command to run the updates and if necessary also run the system-wide upgrade.

$ sudo apt update
$ sudo apt upgrade -y

After the updates and upgrades are complete, we can now add custom PPA to our Ubuntu repository.

2. Add custom PPA

PPA is also known as Personal package Archives allows one to upload Ubuntu source packages to be built and published as an apt repository by Launchpad.

Let’s add the following deadsnakes package into our system with the following command;

$ sudo add-apt-repository ppa:deadsnakes/ppa
Sample output
Third-Party Python Modules

Python modules in the official Ubuntu repositories are packaged to work with the Python interpreters from the official repositories. Accordingly, they generally won't work with the Python interpreters from this PPA. As an exception, pure-Python modules for Python 3 will work, but any compiled extension modules won't.

To install 3rd-party Python modules, you should use the common Python packaging tools.  For an introduction into the Python packaging ecosystem and its tools, refer to the Python Packaging User Guide:

The package sources are available at:

Nightly Builds

For nightly builds, see ppa:deadsnakes/nightly
 More info:
Press [ENTER] to continue or Ctrl-c to cancel adding it.

Hit:1 focal-security InRelease
Get:2 focal InRelease [18.1 kB]                              
Hit:3 main InRelease                               
Hit:4 focal InRelease                          
Hit:5 focal-updates InRelease
Hit:6 focal-backports InRelease
Get:7 focal/main amd64 Packages [22.5 kB]
Get:8 focal/main Translation-en [5168 B]
Fetched 45.7 kB in 1s (70.9 kB/s)                                         
Reading package lists... Done

3. Install Python 3.11 dependencies

Pyuthon 3 depends on other packages to accomplish its installation such as software-properties-common. Let’s install this dependency package now;

$ sudo apt install software-properties-common

Software-properties-common looks like it comes as a default with Ubuntu 20.04. So nothing new will be installed for now.

Run updates again to effect the changes done.

Sample output
Hit:1 focal InRelease
Hit:2 focal InRelease                                                    
Hit:3 main InRelease                                   
Get:4 focal-updates InRelease [114 kB]
Get:5 focal-security InRelease [114 kB]
Get:6 focal-backports InRelease [101 kB]
Get:7 focal-updates/universe amd64 Packages [876 kB]

From the above output, you can see that deadsnakes ppa has been added to the system.

4. Install Python 3.11

We are now ready to install Python 3.11 into our system. Run the following command in your terminal to run the installation.

$ sudo apt install python3.11

You will get the following from your terminal.

Sample output
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libpython3.11-minimal libpython3.11-stdlib python3.11-minimal
Suggested packages:
  python3.11-venv binutils binfmt-support
The following NEW packages will be installed:
  libpython3.11-minimal libpython3.11-stdlib python3.11 python3.11-minimal
0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 4949 kB of archives.
After this operation, 20.3 MB of additional disk space will be used.
Do you want to continue? [Y/n] 
Setting up libpython3.11-minimal:amd64 (3.11.0~a2-1+focal2) ...
Setting up python3.11-minimal (3.11.0~a2-1+focal2) ...
Setting up libpython3.11-stdlib:amd64 (3.11.0~a2-1+focal2) ...
Setting up python3.11 (3.11.0~a2-1+focal2) ...

Press yes to allow installation proceed.

Now we can check our Python version

$ python3.11 --version
Python 3.11.0a2

You can run the Python 3.11 shell like this

$ python3.11
Python 3.11.0a2 (main, Nov 16 2021, 03:12:15) [GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

Type exit() to get out of the shell.

5. Conclusion.

We have successfuly installed Python 3.11 on our Ubuntu distro. Incase of anything check deadsnakes team ppa repository

About Kipkoech Sang

I am a technology enthusiast who loves to share gained knowledge through offering daily tips as a way of empowering others. I am fan of Linux and all other things open source.
View all posts by Kipkoech Sang →

Leave a Reply

Your email address will not be published. Required fields are marked *