software development, devops, and other drivel
Tree lined path

How to Install Python 3.8 on Ubuntu 16.04 and 18.04

Page Navigation

The Zen of Python
The Zen of Python

Python is one of the most popular and most widely used programming languages in the world at this time. The philosophy behind the Python programming language is most likely the reason. It’s very easy to learn with its simple syntax, that same syntax makes the language very readable, therefore easy to understand what someone else wrote. From this the Python ecosystem has grown into a massive juggernaut, encompassing everything from basic scripts to web applications, to machine learning algorithms, process automation and everything in between.

Python 3.8 is the latest major release and brings about a number of changes, some of them are pretty exciting. Such as f-string support, and some improved modules such as asyncio, you can find information about other changes here. If you would like to try these new features and improvements, you’ll of course need to install Python 3.8. I’ll cover doing so on Ubuntu 16.04 which will also work with 18.04.

Building Python

The first method would be to build it yourself, this is of course more involved and may not be an option if you’re in the middle of some other project. Another potential unwanted side effect is having a lot of new tools installed on your system, I like to keep my base system as clean as possible and do builds in either virtual machines or create chroot environments. I wrote another post a couple of years ago explaining how to build Python in on Ubuntu 16.04 in a chroot environment, if you’re interested in building check that out. This guide will work with Ubuntu 18.04 as well.

Installing Python with apt via PPA

If you’re in rush and want to quickly get moving, it’s possible to install Python 3.8 on Ubuntu from a third-party PPA repository. It’s maintained by the deadsnakes team, they’ve been around for awhile and do a really good job with everything.

  1. Make sure everything is up to date
    This step will update the package list and install the prerequisites.

    $ sudo apt update
    $ sudo apt install software-properties-common
  2. Adding the PPA
    This step will add the deadsnakes PPA:

    $ sudo add-apt-repository ppa:deadsnakes/ppa
  3. Install Python 3.8
    Finally, getting down to business. First update the package list one more time to load the deadsnakes packages. And then install Python 3.8!

    $ sudo apt update
    $ sudo apt install python3.8
  4. Wait..there’s more?
    No, that’s it. The only thing left is to enjoy the new features.

Update the Default Version

Now that Python 3.8 is installed on the system you may want to use it by typing python. For this I would recommend using an alias to do this. This method should avoid causes other issues with programs that may still need an older version of Python.

If you want to update your current terminal:

alias python=python3.8

You will also want to add this to the end of your .bashrc file so it will automatically be set each time you start a new terminal.


Queue record scratch, hold on, I’m getting errors trying to create a Python 3.8 virtualenv! If you are getting the following module not found error, you’re not alone.

ModuleNotFoundError: No module named 'distutils.util'

Fortunately the fix for this is pretty easy as well, in order to get distutils.util just install the following package:

$ sudo apt install python3.8-distutils

Note: I put together another post covering the ModuleNotFoundError: No module named ‘distutils.util’ more in depth.

You should be back in business at this point.