Install newer Python releases on Ubuntu 18.04

Ubuntu 18.04 is shipped with Python 3.6, but most of us want to be able to install newer Python versions. I’m using Apt and the deadsnakes PPA, which contains new Python versions packaged for Ubuntu (read here about PPA).

First we install the prerequisites (which might already have been installed), then we add the deadsnakes PPA and finally we install the newer Python version (in this case 3.8).

sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.8

And to verify that the correct version has been installed:

python3.8 --version
Python 3.8.1

The Python versions that came with Ubuntu 18.04 are still there:

python --version
Python 2.7.17
python3 --version
Python 3.6.9

If you want to change python3 to point to the newly installed version, you can change the link /usr/bin/python3.

sudo rm /usr/bin/python3
sudo ln -s /usr/bin/python3.8 /usr/bin/python3
python3 --version
python 3.8.1

NOTE! Don’t change python to point to any python3 version. There are still software that depends on 2.7 and it will break things. python on Ubuntu still needs to be version 2.7.

Comments are closed.