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
🌐
TecAdmin
tecadmin.net β€Ί install-python-3-8-ubuntu
How to Install Python 3.8 on Ubuntu, Debian and LinuxMint – TecAdmin
April 26, 2025 - This tutorial helped you for installing Python 3.8 on Ubuntu, Debian, and Linux Mint systems by compiling it from source code.
🌐
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 ...
Discussions

linux - How to install python 3.8 directly in /usr/bin? - Stack Overflow
Releases Keep up-to-date on features we add to Stack Overflow and Stack Internal. ... Find centralized, trusted content and collaborate around the technologies you use most. Learn more about Collectives ... Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... Trying to install python 3.8 ... More on stackoverflow.com
🌐 stackoverflow.com
How to install Python 3.8
I tried to install gensim using pip3 install -U gensim but it died with the message that python 3.8 is required. However, Rocky ships with only 3.6 as far as I can see. My web search shows that to upgrade, I have to rebuild python from scratch. Is this the only way?? More on forums.rockylinux.org
🌐 forums.rockylinux.org
4
0
January 3, 2022
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
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
🌐
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 …
🌐
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.
🌐
Oreate AI
oreateai.com β€Ί blog β€Ί how-to-install-python-python-38-on-linux β€Ί 6f231d8ac43fe23656dec11ab8b5bb54
How to Install Python (Python 3.8) on Linux - Oreate AI Blog
December 22, 2025 - Go to the official Python website and download the latest installation package: wget https://www.python.org/ftp/python/3.8.3/Python-3.8.3.tgz tar zxvf Python-3.8.3.tgz -C ./ cd Python-3.8.3/ Set the installation directory, first check the current ...
Find elsewhere
🌐
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 - In the following tutorial, you will learn how to install Python 3.8 using the command terminal and how to download and compile as an alternative method.
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
🌐
Position Is Everything
positioniseverything.net β€Ί home β€Ί how to install python 3.8 on linux: a step-by-step guide
How to Install Python 3.8 on Linux: A Step-by-Step Guide - Position Is Everything
May 16, 2026 - Any Linux distribution: Build Python 3.8 from source or use pyenv. On Ubuntu, the Deadsnakes PPA is one of the most convenient ways to install older or alternate Python versions alongside the default system Python.
🌐
LinuxVox
linuxvox.com β€Ί blog β€Ί install-python-38-linux
Installing Python 3.8 on Linux: A Comprehensive Guide β€” linuxvox.com
This blog will guide you through the process of installing Python 3.8 on Linux, covering fundamental concepts, usage methods, common practices, and best practices.
🌐
Rocky Linux Forum
forums.rockylinux.org β€Ί rocky linux help & support
How to install Python 3.8 - Rocky Linux Help & Support - Rocky Linux Forum
January 3, 2022 - I tried to install gensim using pip3 install -U gensim but it died with the message that python 3.8 is required. However, Rocky ships with only 3.6 as far as I can see. My web search shows that to upgrade, I have to r…
🌐
Linuxize
linuxize.com β€Ί home β€Ί python β€Ί how to install python 3.8 on debian 10
How to Install Python 3.8 on Debian 10 | Linuxize
March 2, 2020 - This tutorial covers how to install Python 3.8 on Debian 10. We'll also show you how to create a virtual environment.
🌐
Reddit
reddit.com β€Ί r/linuxmint β€Ί how to install python 3.8 on linuxmint
r/linuxmint on Reddit: How to Install Python 3.8 on LinuxMint
October 16, 2019 -

At the writing time of this article Python latest stable version 3.8 series is available to install. This article will help you to install Python 3.8 on LinuxMint operating system. You can visit here to read more about Python releases.

Step 1 – Prerequisites

Use the following command to install prerequisites for Python before installing it.

sudo apt-get install build-essential checkinstall
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev \     libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev

Step 2 – Download Python 3.8

Download Python from the python official site.

Step 3 – Install Python 3.8

After download extract the .tar.xz file. Then inside the Python-3.8.0 folder open terminal. Use below set of commands to install Python 3.8

./configure
make
make test
sudo make install

All Done! This will install Python as ``python3``. Open the terminal and see yourself!

🌐
LinuxShout
linux.how2shout.com β€Ί home β€Ί install python 3.9 or 3.8 on ubuntu 22.04 lts jammy jellyfish
Install Python 3.9 or 3.8 on Ubuntu 22.04 LTS Jammy JellyFish
April 1, 2024 - Install Python 3.9 on Ubuntu 22.045. Install Python 3.8 on Ubuntu6. Set the default Python version7. Uninstall Python and PPA Β· Python is freely available for the common operating systems. The programming language is standard equipment in many Linux distributions.
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
🌐
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 5
54

Amazon has it's own Linux with extras, the command is:

    sudo amazon-linux-extras install python3.8

taken from https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-install-linux.html but after installing 3.7 from there, there is the above update command appearing during the install telling how to upgrade. Ahh the convolution of hosted virtual machines, still easier than trying to get a console command line login on any other Linux on AWS.

It does rebuild the python to 3.8, cleaning up files from 3.7, so boom a clean build of 3.8 thanks to Amazon.

All that being said, the default "python" will still be 2.7 as there is no backward compatibility, and many think getting rid of 2.7 will cause problems.

So what NOT TO DO NEXT as we are done is:

    sudo rm /usr/bin/python  (which is only a link to /usr/bin/python2.7)
    sudo ln -s /usr/bin/python3.8 /usr/bin/python

but usually peeps simply type python3.8 to specifically run the new version.

2 of 5
6

These answers are now out of date as of Amazon Linux 2023. Amazon Linux 2023 FAQ

Q: Does AL2023 have Amazon-Linux-Extras like AL2?

A: No, AL2023 does not have extras. For higher-level software packages like language runtimes, we will use the quarterly release where we will add major/minor updates to packages as separate namespaced packages in addition to the default package provided in the repository. For example, default Python version in Amazon Linux 2023 may be 3.8, but we will add Python 3.9 (python39) as a separate namespaced package whenever it is made available. These additional packages will closely follow their upstream release cadence and support model and their support policies can be accessed by the package manager for compliance and security use cases. Default packages will continue to be supported throughout the life of AL2023.

Python is installed by default as python3 exact version is managed by Amazon. It is possible to pick a different version, but I have not found the instructions, since the currently install 3.9 works for my needs.

python3 --version
Python 3.9.16

python3x --version
always generated
-bash: python3x: command not found
regardless of choice of x

🌐
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.