install python3.9 on ubuntu 18.04 20.04

More Less
2 min readFeb 6, 2023

Installing Python 3.9 on Ubuntu with apt is a relatively straightforward process and will only take a few minutes:

  1. Start by updating the packages list and installing the prerequisites:
sudo apt update
sudo apt install software-properties-common

2. Next, add the deadsnakes PPA to your sources list:

sudo add-apt-repository ppa:deadsnakes/ppa

When prompted press Enter to continue:

Press [ENTER] to continue or Ctrl-c to cancel adding it.
  • Press [ENTER] to continue or Ctrl-c to cancel adding it.Copy

3. Once the repository is enabled, install Python 3.9 with:

sudo apt install python3.9

4. At this point, Python 3.9 is installed on your Ubuntu system and ready to be used. You can verify it by typing:

python3.9 --versionCopy
Python 3.9.16

Then pip can be installed.

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3.9 get-pip.py

It is important you use python3.9 instead of just python3, to ensure pip is installed for python 3.9.

If you see any permissions errors, you may need to use

python3.9 get-pip.py --user

If you get an error like No module named 'distutils.util' when you run python3.9 get-pip.py, and you…

--

--