Published: July 22, 2026
Read: 8 min
In: Technology & Development

Written by

Reviewed by

Last updated: June 25, 2023

Expert verified

SVG Image

TL;DR

To install Python 3 on Ubuntu, you can follow these steps:

  1. Open the Terminal by pressing Ctrl + Alt + T.
  2. Run the command sudo apt update to update the package lists.
  3. Run the command sudo apt upgrade to upgrade the installed packages.
  4. Install Python 3 by running sudo apt install python3 in the Terminal.
  5. Verify the installation by running the python3 --version to see the Python version installed on your system.

Configuring Python 3 on Ubuntu is crucial for optimal usage. Setting up environment variables and installing Python packages. addressing common installation errors, including python3 command not found, dependency issues, permission denied, incorrect Python version, and environment variable setup.

Explore the guide below for a step-by-step guide on how to install Python 3, configure it, and common errors with possible solutions.

Python, a powerful and versatile programming language, is widely used in various industries, from web development and data analysis to artificial intelligence and scientific research. With its clean syntax and extensive library support, Python 3 has gained immense popularity across various domains, from web development to data science and machine learning. If you’re an aspiring Python developer or a seasoned programmer, having Python 3 installed on your Ubuntu system is crucial. In this comprehensive guide, I will walk you through the step-by-step process to Python 3 on Ubuntu, configuring it, and common errors with possible solutions.

How to Install Python 3 on Ubuntu

To install Python 3 on Ubuntu, you’ll need a compatible version of Ubuntu (such as 22.04 LTS), sufficient free disk space, at least 1 GB of RAM, a modern x86-based processor, and an active internet connection for downloading and updating Python, and its libraries. Follow these steps:

  1. Open the Terminal by pressing Ctrl + Alt + T.
opening terminal 15
  1. Run the following command to update the package:

<strong>sudo apt update</strong>
  1. This command will update the package lists for upgrades and new package installations.
updating system packages 3
  1. After the update process completes, run the following command to upgrade:

<strong>sudo apt upgrade</strong>
  1. The command will upgrade the installed packages.
upgrading system packages 2
  1. Ubuntu provides Python 3 through its official repository. For installation, open the Terminal and execute the following command to install Python 3 on Ubuntu:

<strong>sudo apt install python3</strong>
  1. After the execution of the command, Python 3 will be installed along with the required dependencies.
installing python3 on ubuntu
  1. To check Python 3 is correctly installed on your system, run the following command: 

<strong>python3 --version</strong>
  1. If the installation was successful, the Terminal will display the Python version installed on your system.
verifying python3 installation

How to Configure Python 3 on Ubuntu

Configuring Python 3 on Ubuntu is essential for ensuring optimal usage and leveraging its benefits. This section will cover two crucial aspects: setting up environment variables and installing Python packages and libraries. You can customize your Python environment and enhance its functionality by following the steps below.

1. Setting Up Environment Variables

To ensure Python functions properly on Ubuntu, you need to configure the environment variables. This allows for seamless execution and accessibility. Follow these steps to set up environment variables:

  1. Open the Terminal.
  2. Execute the following command to open the .bashrc file in a text editor:

<strong>nano ~/.bashrc</strong>
opening bashrc file in text editor
  1. Scroll to the bottom of the file and add the following lines:

<strong>export PATH="/usr/local/bin:$PATH"</strong>
<strong>export PATH="/usr/local/sbin:$PATH"</strong>
  1. It will set the environment variables for the proper functioning of python.
setting environment variables
  1. Save the changes by pressing Ctrl + O and exit the text editor by pressing Ctrl + X.
saving and exiting the file
  1. To apply the changes, run the following command:

<strong>source ~/.bashrc</strong>
applying changes

2. Installing Python Packages and Libraries

Python packages and libraries expand the capabilities of the language. With these libraries, you can supercharge your Python projects and tap into a vast array of functionality. To install additional packages using pip, the package installer for Python, follow these steps:

  1. Launch the Terminal window and run the following command to install pip:

<strong>sudo apt install python3-pip</strong>
  1. Once pip is installed, you can use it to install Python packages.
installing pip
  1. To install the python packages, run the following command: