To install Python 3.8 on Ubuntu version 23

Open your terminal and run these commands:

Install build dependencies

sudo apt-get update

sudo apt-get install -y build-essential libssl-dev zlib1g-dev libbz2-dev \
                        libreadline-dev libsqlite3-dev wget curl llvm \
                        libncurses5-dev libncursesw5-dev xz-utils tk-dev \
                        libffi-dev liblzma-dev python3-openssl git

Download and extract Python 3.8 source code

mkdir ~/python38
cd ~/python38
wget https://www.python.org/ftp/python/3.8.16/Python-3.8.16.tgz
tar -xf Python-3.8.16.tgz

cd Python-3.8.16

Configure the build

./configure --enable-optimizations

Compile the source code

make -j$(nproc)

Install Python

sudo make install

Verify the installation

python3.8 --version

To create a virtual environment specify the Python version.

Example: python3.8 -m venv venv

Answer from GODFREY NDUNGU on askubuntu.com
🌐
LinuxCapable
linuxcapable.com β€Ί home β€Ί ubuntu β€Ί how to install python 3.8 on ubuntu 26.04, 24.04 and 22.04
How to Install Python 3.8 on Ubuntu 26.04, 24.04 and 22.04 - LinuxCapable
May 8, 2026 - Install Python 3.8 on Ubuntu 26.04, 24.04 and 22.04 via Deadsnakes PPA or source. Manage versions safely without breaking system tools.
Discussions

How to install python 3.8.12 on /usr/bin/python? - Stack Overflow
I want to install python 3.8.12 on my ubuntu . I followed this link: https://tecadmin.net/install-python-3-8-ubuntu/ and installed python in my Download folder and I can't find it at /usr/bin/pyth... More on stackoverflow.com
🌐 stackoverflow.com
How can I install Python 3.8 on Ubuntu 16.04? (ppa:deadsnakes doesn't support Ubuntu 16.04 anymore)
Ubuntu 16.04 reached End of Life almost a year ago. Is there any reason why you can't use a supported version? More on reddit.com
🌐 r/Ubuntu
13
1
March 5, 2022
How do I install pip for python 3.8 on Ubuntu without changing any defaults? - Stack Overflow
I'm trying to install pip for Python 3.8 on an Ubuntu 18.04 LTS. I know this has been asked way too many times. But those questions do not concern keeping Ubuntu's defaults specifically. And the More on stackoverflow.com
🌐 stackoverflow.com
How to Install Python 3.8 on LinuxMint
So whilst there aren't many breaking changes in 3.8, replacing the default version of python is not a recommenced thing to do as it might break some core parts of Linux Mint. Much better to use something like pyenv. More on reddit.com
🌐 r/linuxmint
9
35
October 16, 2019
🌐
The Hitchhiker's Guide to Python
docs.python-guide.org β€Ί starting β€Ί install3 β€Ί linux
Installing Python 3 on Linux β€” The Hitchhiker's Guide to Python
$ sudo apt-get install software-properties-common $ sudo add-apt-repository ppa:deadsnakes/ppa $ sudo apt-get update $ sudo apt-get install python3.8 Β· If you are using other Linux distribution, chances are you already have Python 3 pre-installed ...
🌐
Linuxize
linuxize.com β€Ί home β€Ί python β€Ί how to install python 3.8 on ubuntu 18.04
How to Install Python 3.8 on Ubuntu 18.04 | Linuxize
November 5, 2019 - In this tutorial we'll cover two different ways to install Python 3.8 on Ubuntu 18.04. The first option is to install the deb package from the deadsnakes PPA, and the second one is by building from …
🌐
TecAdmin
tecadmin.net β€Ί install-python-3-8-ubuntu
How to Install Python 3.8 on Ubuntu, Debian and LinuxMint – TecAdmin
April 26, 2025 - The Python team has released its latest version Python 3.8 for general use. You can download the latest stable version Python 3.8 series and install it on your system. This article will help you to install Python 3.8.12 on Ubuntu, Debian, and LinuxMint operating systems. You can visit here ...
🌐
Medium
eazytechy.medium.com β€Ί how-to-install-python-3-8-on-ubuntu-22-04-e4ad4d37ad93
How to Install Python 3.8 on Ubuntu 22.04 | by Sumit Jain | Medium
January 29, 2023 - Before proceeding with the tutorial, ... ... The first and easiest solution for Ubuntu users would be to import the β€œdeadsnakes” team Launchpad PPA....
🌐
Linux Genie
linuxgenie.net β€Ί home β€Ί how to install python 3.8 on ubuntu 22.04
How to Install Python 3.8 on Ubuntu 22.04 - Linux Genie
July 21, 2023 - You can install Python 3.8 on Ubuntu 22.04.2 using the command β€œsudo apt install python3.8”. Moreover, you are allowed to create a separate environment for your Python-based projects with β€œsudo apt install python3.8-venv -y”.
Find elsewhere
🌐
Liquid Web
liquidweb.com β€Ί home β€Ί how to install and update python to 3.9 in ubuntu
How to Install and Update Python to 3.9 in Ubuntu | Liquid Web
January 15, 2026 - After a successful installation, remove the downloaded archive to save disk space Β· root@host:~# cd /usr/src/ root@host:~# rm -f Python-3.8.6.tgz
🌐
tech.serhatteker.com
tech.serhatteker.com β€Ί post β€Ί 2019-12 β€Ί how-to-install-python38-on-ubuntu
How to Install Python 3.8 on Ubuntu - Tech Blog | Serhat Teker
December 25, 2019 - $ sudo apt update $ sudo apt upgrade $ sudo apt dist-upgrade $ sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget Β· Now create a temporary directory and download the python source code: $ mkdir ~/tmp $ cd ~/tmp $ wget https://www.python.org/ftp/python/3.8.1/Python-3.8.1.tgz
Top answer
1 of 3
29

This post is community wiki so as to not claim the credit of @Kulfy's comment. This procedure worked on Ubuntu 18.04.

DON'T EVER CHANGE DEFAULT PYTHON!!! It may cause your system to break and some applications won't even run. It's far far far better to invoke python3.8 using python3.8 command

When installing python3.8, do the following

$ sudo apt-get install python3.8 python3.8-dev python3.8-distutils python3.8-venv

For most people this will be acceptable as they will be using a virtual environment for development. Construct a virtual environment and activate it as you usually would. This will leave you in a terminal where python resolves to python3.8:

$ python3.8 -m venv dev3.8/
$ source dev3.8/bin/activate
(dev3.8) $ which python
...dev3.8/bin/python
(dev3.8) $ python --version
Python 3.8.0

Neglecting to install python3.8-venv will result in an unhelpful error, that suggests you should install python-venv which resolves to python3.6-venv:

$ python3.8 -m venv dev3.8/
The virtual environment was not created successfully because ensurepip is not
available.  On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.

    apt-get install python3-venv

You may need to use sudo with that command.  After installing the python3-venv
package, recreate your virtual environment.

Failing command: ... (trimmed for formatting)
2 of 3
9

Step 1: Install the latest version of python. Currently, 3.8 is the latest

sudo apt install python3.8

Step 2: Add Python 3.6 & Python 3.8 to update-alternatives

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6.9
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8.1

Step 3: Update Python 3 to point to Python 3.7

By default, Python 3.6 is pointed to Python 3. So, we run python3 it will execute as python3.6 but we want to execute this as python3.8

sudo update-alternatives --config python3

You should get a similar output. Now type 2 and hit enter for Python 3.

Step 4: Test the version of python

Finally test the current version of python by typing

python3 -V
🌐
LinuxVox
linuxvox.com β€Ί blog β€Ί install-python-38-ubuntu
Installing Python 3.8 on Ubuntu: A Comprehensive Guide β€” linuxvox.com
Installing Python 3.8 on Ubuntu is a straightforward process, especially with the help of the DeadSnakes PPA. By following the steps outlined in this blog post, you can have Python 3.8 up and running on your system.
🌐
Reddit
reddit.com β€Ί r/ubuntu β€Ί how can i install python 3.8 on ubuntu 16.04? (ppa:deadsnakes doesn't support ubuntu 16.04 anymore)
r/Ubuntu on Reddit: How can I install Python 3.8 on Ubuntu 16.04? (ppa:deadsnakes doesn't support Ubuntu 16.04 anymore)
March 5, 2022 -

I used to use the following gist to install Python 3.8 on Ubuntu 16.04:

# install PPA
sudo add-apt-repository ppa:deadsnakes/ppa

# update and install
sudo apt update
sudo apt install python3.8 python3.8-dev python3.8-venv

However, ppa:deadsnakes doesn't support Ubuntu 16.04 anymore, and the above script doesn't work:

 > [6/6] RUN apt install -y python3.8:
#9 0.222
#9 0.222 WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
#9 0.222
#9 0.224 Reading package lists...
#9 0.960 Building dependency tree...
#9 1.098 Reading state information...
#9 1.148 E: Unable to locate package python3.8
#9 1.148 E: Couldn't find any package by glob 'python3.8'
#9 1.148 E: Couldn't find any package by regex 'python3.8'

How can I install Python 3.8 on Ubuntu 16.04?

🌐
Medium
medium.com β€Ί analytics-vidhya β€Ί installing-python-3-8-3-66701d3db134
Installing Python 3.8.3 on Ubuntu 16.04, change the default version of python to the new version, and why is my terminal not working. | by RL | Analytics Vidhya | Medium
June 28, 2020 - On the first line use your previous version(in my case its python3.5) and set the priority number to 1. On the second line use the new installed python version and set the priority to 2. According to Ubuntu <priority> is an integer; options with higher numbers have higher priority in automatic mode. sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 2
🌐
Tutorials24x7
tutorials24x7.com β€Ί python β€Ί how-to-install-python-38-on-ubuntu-1804-lts
How To Install Python 3.8 On Ubuntu 18.04 LTS | Tutorials24x7
March 22, 2020 - In this tutorial, we will discuss all the steps required to install Python 3 i.e Python 3.8 on the popular Linux distribution Ubuntu. It provides the steps for Ubuntu 18.04 LTS.
Top answer
1 of 6
43

While we can use pip directly as a Python module (the recommended way):

python -m pip --version

This is how I installed it (so it can be called directly):
Firstly, make sure that command pip is available and it isn't being used by pip for Python 2.7

sudo apt remove python-pip

Now if you write pip in the Terminal, you'll get that nothing is installed there:

pip --version

Output:

Command 'pip' not found, but can be installed with:

sudo apt install python-pip

Install python3.8 and setup up correct version on python command using update-alternatives (as done in the question).

Make sure, you have python3-pip installed:
(This won't work without python3-pip. Although this will install pip 9.0.1 from python 3.6, we'll need it.)

sudo apt install python3-pip

This will install pip 9.0.1 as pip3:

pip3 --version

Output:

pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)

Now, to install pip for Python 3.8, I used pip by calling it as a python module (ironic!):

python -m pip install pip

Output:

Collecting pip
  Downloading https://files.pythonhosted.org/packages/36/74/38c2410d688ac7b48afa07d413674afc1f903c1c1f854de51dc8eb2367a5/pip-20.2-py2.py3-none-any.whl (1.5MB)
  100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 1.5MB 288kB/s
Installing collected packages: pip
Successfully installed pip-20.2

It looks like, when I called pip (which was installed for Python 3.6, BTW) as a module of Python 3.8, and installed pip, it actually worked.

Now, make sure your ~/.local/bin directory is set in PATH environment variable:
Open ~/.bashrc using your favourite editor (if you're using zsh, replace .bashrc with .zshrc)

nano ~/.bashrc

And paste the following at the end of the file

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi

Finally, source your .bashrc (or restart the Terminal window):

source ~/.bashrc

Now if you try running pip directly it'll give you the correct version:

pip --version

Output:

pip 20.2 from /home/qumber/.local/lib/python3.8/site-packages/pip (python 3.8)

Sweet!

2 of 6
16

As suggested in official documentation you can try with get-pip.py.

wget https://bootstrap.pypa.io/get-pip.py
python3.8 get-pip.py

This will install pip as pip3.8.

Make sure you have python3.8-distutils installed to avoid below error

"No module named 'distutils.cmd'" error.

You can install distutils using:

sudo apt install python3.8-distutils
🌐
DEV Community
dev.to β€Ί mortoray β€Ί how-to-install-python-3-8-on-ubuntu-1bp4
How to install Python 3.8 on Ubuntu? - DEV Community
June 16, 2019 - I encountered the same problem. Finally I use pyenv to install Python 3.8 on Ubuntu 18.04.
🌐
PhoenixNAP
phoenixnap.com β€Ί home β€Ί kb β€Ί sysadmin β€Ί how to install python 3 on ubuntu
How to Install Python 3 on Ubuntu | phoenixNAP KB
February 5, 2025 - Follow our step-by-step installation guide and install Python 3 on Ubuntu using APT, PPA, or from the source code.
🌐
LinuxVox
linuxvox.com β€Ί blog β€Ί how-to-install-python-3-8-on-ubuntu-18-04
How to Install Python 3.8 on Ubuntu 18.04 β€” linuxvox.com
If you need Python 3.8 for your projects while keeping the system’s default Python 3.6 intact (critical for system stability), this guide will walk you through two reliable installation methods: using the deadsnakes PPA (simplest) and compiling from source (for advanced control). We’ll also cover verifying the installation, setting Python 3.8 as the default (optional), and uninstalling if needed. ... An Ubuntu 18.04 LTS system (physical, virtual, or cloud-based).
🌐
DedicatedCore
dedicatedcore.com β€Ί home β€Ί how to install python 3 on ubuntu 20.04
How to Install Python 3 on Ubuntu 20.04 - DedicatedCore Blog
October 16, 2024 - You can follow the instructions in this tutorial for Python installation on Ubuntu 18.04 or 20.04. Operating system scripts are typically written in the popular programming language Python. It is sufficiently adaptable to be used in both web development and app creation. You may learn how to install Python 3.8 on Ubuntu 18.04 | 20.04 here.