How to Install Python 3.8 on Ubuntu 22.04

Python is a programming language widely recognized for its simple syntax and structure. It is a high-level programming language with cross-platform compatibility. Python supports large standard libraries, third-party packages, and frameworks, empowering developers to create a wide range of applications. It is an ideal choice to analyze big data, train and predict computer models, and detect and recognize patterns in machine learning.

The main objective of this post is to provide you with a detailed demonstration of how to install Python 3.8 on Ubuntu 22.04.

How to Install Python 3.8 on Ubuntu 22.04.2?

Following the sequential steps outlined below will install Python 3.8 release on Ubuntu 22.04.2.

Step 1: Add “deadsnakes” PPA to Your Machine

The below command will be used to add PPA “deadsnakes” to your machine such as Ubuntu 22.04.2:

sudo add-apt-repository ppa:deadsnakes/ppa

During installation, the system will ask you to press “Enter” from your keyboard to continue and complete the process:

The installation process has been finished without any errors occurring.

Step 2: Install Python 3.8 via “apt”

The command mentioned below will be used to install the Python package on your Machine:

sudo apt install python3.8 -y

Step 3: Confirmation

Once the installation process of Python has finished, you can verify it using the below-mentioned command:

python3.8 --version

Now, you have the newest released version of Python on your Ubuntu machine.

Step 4: Install Python3.8 Virtual Environment

The below command will install a virtual environment on your system:

sudo apt install python3.8-venv -y

The main purpose of this virtual environment is to create an isolated project without affecting the global Python installation or other projects.

Step 5: Update Your Ubuntu Machine

To ensure your Ubuntu machine is up to date with the new software packages, run the “update” command:

sudo apt update

As you can see that your Ubuntu machine is up to date with the new packages.

How to Create a Virtual Environment on Ubuntu 22.04.2?

The following instructions will be followed to create a new virtual environment for Python-based projects.

Step 1: Create a Virtual Environment for Python Project

The command provided in the following will create a new environment named “pygenie” for an isolated Python project:

python3.8 -m venv pygenie

Step 2: Activate “pygenie” Virtual Environment

Run the following command to activate and start the “pygenie” virtual environment:

source pygenie/bin/activate

Step 3: Install Python Packages

After you have activated the “pygenie” virtual environment, install the Python packages and libraries within the “pygenie” using the “pip” package installer:

pip install numpy

Step 4: Run Python Script

Here is the simple Python script that can be run inside the “pygenie” virtual environment:

import numpy as np

# Create a numpy array

arr = np.array([1, 2, 3, 4, 5])

# Print the array


Step 5: Deactivate “pygenie” Virtual Environment

Using the “deactivate” command will deactivate the “pygenie” virtual environment:


That’s it, you have deactivated the virtual environment.

How to Uninstall Python 3.8 from Ubuntu 22.04.2?

The following instructions will remove the Python package along with its dependencies and libraries.

Step 1: Uninstall Python 3.8

You can uninstall the Python packages and their configuration files by running the following command:

sudo apt purge python3.8 -y

You have successfully installed the Python 3.8 release of Python on your Ubuntu 22.04.2.


Python, with its simple syntax and readability, empowers users to create a wide range of applications. These applications include various domains such as web development, big data analysis, image classification and detection, computer model prediction, and much more.

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

Through this educational post, we have demonstrated you to install Python 3.8 on the Ubuntu machine. Additionally, we also explained the process of creating an isolated environment for Python-based projects.

Print Friendly, PDF & Email