Categories: Ubuntu 18.04

How To Install Python 3.9 on Ubuntu 18.04

Python is an object-oriented, high-level programming language. It is an open source with a large community. Python is used as key languages among the top tech companies like Google.

The latest stable version Python 3.9 is out with several improvements and security updates. It included multiple new modules, improved existing modules and many other features.

This tutorial will help you to install Python 3.9 on Ubuntu 18.04 LTS system. You will find two methods to install Python. First method will use deadsnakes PPA to install Python. The second method will use Python’s source code for the installation.

Sponsored

Follow the below tutorial and choose one method to install Python 3.9. Both the methods are tested with latest Ubuntu 18.04 system.

Prerequisites

Before beginning the Python installation, install some required packages on your system. Login to your Ubuntu system and execute following commands:

sudo apt update 
sudo apt install software-properties-common 

Install Python 3.9 Using Apt-Get

The Apt package manager provides simple way for installing Python 3.9 on Ubuntu system. Follow the steps below:

  • Open a terminal on your system and configure deadsnakes PPA to your system.
    sudo add-apt-repository ppa:deadsnakes/ppa 
    
  • Once your added the ppa on your Ubuntu system, update the apt cache and install Python 3.9 on Ubuntu.
    sudo apt update 
    sudo apt install python3.9 
    
  • Wait for the installation to complete. Check the Python version by executing:
    python3.9 -V 
    
    Python 3.9.0
    

That’s it. Python 3.9 is installed on your Ubuntu system and ready to use.

Sponsored

Install Python 3.9 Using Source Code

As the Debian packages are available, We don’t recommend to install Python 3.9 packages from source code. But in some cases you may need to install Python from source code.

So follow the below instructions to install Python 3.9 using source code on Ubuntu 18.04 Linux system.

  • First of all, install essential packages for compiling source code. Open a terminal and execute following commands:
    sudo apt install wget build-essential checkinstall 
    sudo apt install libreadline-gplv2-dev libncursesw5-dev libssl-dev 
        libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev 
    
  • Now, download the Python 3.9 source code from official download site. Switch to a relevent directory and use wget to download source file.
    cd /opt 
    sudo wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tgz 
    
  • Next, extract the downloaded archive file and prepare the source for the installation.
    tar xzf Python-3.9.0.tgz 
    cd Python-3.9.0 
    sudo ./configure --enable-optimizations 
    
  • Python source is ready to install. Execute make altinstall command to install Python 3.9 on your system.
    sudo make altinstall 
    

    make altinstall is used to prevent replacing the default python binary file /usr/bin/python.

  • The Python 3.9 has been installed on Ubuntu 18.04 system. Verify the installed version:
    python3.9 -V 
    
    Python 3.9.0
    
  • Remove the downloaded archive to free space
    sudo rm -f /opt/Python-3.9.0.tgz 
    

Conclusion

In this tutorial, you have learned to install Python 3.9 on Ubuntu 18.04 using Apt and source code.

The post How To Install Python 3.9 on Ubuntu 18.04 appeared first on TecAdmin.

Ubuntu Server Admin

Recent Posts

Canonical Releases Ubuntu 25.04 Plucky Puffin

The latest interim release of Ubuntu introduces “devpacks” for popular frameworks like Spring, along with…

2 days ago

Ubuntu 25.04 (Plucky Puffin) Released

Ubuntu 25.04, codenamed “Plucky Puffin”, is here. This release continues Ubuntu’s proud tradition of integrating…

3 days ago

Extended Security Maintenance for Ubuntu 20.04 (Focal Fossa) begins May 29, 2025

Ubuntu released its 20.04 (Focal Fossa) release 5 years ago, on March 23, 2020. As…

3 days ago

Ubuntu 20.04 LTS End Of Life – activate ESM to keep your fleet of devices secure and operational

Focal Fossa will reach the End of Standard Support in May 2025, also known as…

4 days ago

Ubuntu MATE 25.04 Release Notes

Ubuntu MATE 25.04 is ready to soar! 🪽 Celebrating our 10th anniversary as an official…

5 days ago

Ubuntu Weekly Newsletter Issue 887

Welcome to the Ubuntu Weekly Newsletter, Issue 887 for the week of April 6 –…

6 days ago