How do I Update my Python Version in Ubuntu?

How do I Update my Python Version in Ubuntu

Python is the most used programming language at present for Task Automation, Developing Data-Centric Software Systems, and Data Visualization. It is also used as a scripting language and it provides an Object-Oriented Programming Approach. Updating Python to the latest version ensures the compatibility of packages and stability of the Ubuntu system.

This article elaborates on the process of updating Python to the Latest Version in Ubuntu.

How do I Update my Python Version in Ubuntu?

Ubuntu Repositories do not usually contain updated versions of a package and due to update delay you might get the updated version later on in the future. To manually get the latest Python Version, follow the steps below.

Step 1: Check Existing Python Version

Let’s first check the already installed Python version using the following “python” command:

Step 2: Update Existing Packages

Before Updating Python ensure all of your packages are up-to-date using the update and upgrade commands:

sudo apt update && sudo apt upgrade

Step 3: Add the “Software Properties Common” Tool

The “Software Properties Common” tool manages the software repositories. With this tool, you can add, manage, enable, or disable any software repository. To install the “Software Properties Common” tool, use the command:

sudo apt install software-properties-common

Step 4: Install CA Certificates

The CA Certificate verifies the identity of 3rd party applications and encrypts the data between the 3rd party application and your system. To install CA Certificates use the command:

sudo apt-get install -reinstall ca-certificates

Step 5: Add the Repository

Once the CA Certificates are validated, add the Python repository which will also inform you if any recent packages are available for Ubuntu. Add the repository using the command:

add-apt-repository ppa:deadsnakes/ppa

It will ask for package installation confirmation, press “Enter” to continue:

Step 6: Renew Cache and Search for the Newest Version

Search the Package with the apt-cache command. The “apt-cache” is a local database of packages and to search for a specific package we can use the “search” command with it:

sudo apt-get update && apt-cache search python3.1

The “apt-cache search” returns the latest available version. In our case its “python3.12”:

Step 7: Install the Latest Python Version

Install the latest version now using the command:

sudo apt-get install python3.12

It will ask for confirmation to add the packages as additional disk space will be used. Enter “Y” and click “Enter” to continue installing “python3.12”:

Step 8: Create a Symbolic Link for Python

After the python3.12 installs, create a symbolic link for the new Python Library. The Symbolic Link refers to the files and directories in Ubuntu as a single file for ease of access. Create a Symbolic Link for Python that acts as a shortcut key to the file and folder using the command:

sudo ln -s /usr/bin/python3.12 /usr/bin/python

Step 9: Verify the Python Version

Once the Latest Python Version is installed and the symbolic link for Python is created, verify the version of Python using the command:

python --version

This is how you can upgrade the Python version in Ubuntu.


Python in Ubuntu can be updated using the deadsnakes repository in CLI. To Update Python, the “Software Properties Common” tool is used along with the “deadsnakes/ppa” repository. This article explained how you can update your Python to the latest version by using these tools and repositories.

Similar Posts