0 3 mins read
| Published on: December 2, 2022 | Last updated on: February 16, 2023

We’ll show you how to install python 3.9 on ubuntu! To get Python 3.9 running on Ubuntu LTS, you can choose one of two routes. Either download Python 3.9 from the deadsnakes PPA or compile it from scratch.

Python is a widely used programming language. There is no denying this. From the simplest of programs to the most complex machine learning algorithms, all are possible in this language. Python’s clear and logical grammar has made it a popular choice among programmers of all skill levels.

Downloads of Python 3.9, the most recent significant update to the Python programming language, are now available. A few examples of the many new features include new dict operators, str functions, and support for the IANA time zone. There have also been several more enhancements.

The installation process for Ubuntu is same across all variants based on Ubuntu, including Kubuntu, Linux Mint, and Elementary OS.

How to install Python 3.9 Using Apt on Ubuntu 16.04

This is an easy and quick way to install python 3.9 installed on Ubuntu using the apt package manager.

  1. Install the requirements and the current set of packages:
sudo apt update
sudo apt install software-properties-common

Add the deadsnakes PPA to the sources list of your system:

sudo add-apt-repository ppa:deadsnakes/ppa

To proceed, you must hit [Enter] when instructed to do so.

Once the repository has been activated, you will be able to install Python 3.9 by issuing the following command:

sudo apt install python3.9

Type in the following to check that the installation was completed successfully:

python3.9 --version
Python 3.9.1+

That sums it up well. Python 3.9 is now ready for use on your Ubuntu system and has been successfully installed.

How to install Python 3.9 using the source code on Ubuntu 16.04

Compiling Python from its source code gives you the ability to install the most recent version of Python as well as tweak the build parameters. On the other hand, you won’t be able to use the apt package manager to manage and update your Python installation.

The compilation of Python 3.9 from its source code may be broken down into the following steps:

Install the prerequisites for building Python, which are as follows:

sudo apt update
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev

Using wget, get the source code for the most recent version of Python from the Python download page:

wget https://www.python.org/ftp/python/3.9.1/Python-3.9.1.tgz

When the download is finished, you may extract the gzipped archive as follows:

tar -xf Python-3.9.1.tgz

Move to the directory containing the Python source code, and then execute the configure script. This script will carry out a series of tests to ensure that all of the necessary dependencies are available on your system.

cd Python-3.9.1./configure --enable-optimizations

The --enable-optimizations option optimizes the Python binary by running multiple tests. This makes the build process slower.

Kick off the process of building Python 3.9:

make -j 12

Change the -j option to match to the number of cores in your CPU to make the building process go more quickly. Simply enter nproc into your search bar to get the number..

Once the Python binaries have been built, use the following command to install them into your system.

sudo make altinstall

Because we’ll be overwriting the system’s default python3 binary later, we’re using altinstall rather than install.

That’s all. Python 3.9 is now installed and ready for usage. To confirm, type:

python3.9 --version

The following Python version should be shown in the output:

Python 3.9.1


Python 3.9 is not included in the normal Ubuntu 16.04 repository.

We’ve taught you how to install Python 3.9 on your Ubuntu computer. You may now start building your Python 3.9 project.

Let us know what you think in the comments section below..


Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

Copyright @2022-2024 All Right Reserved – PCPlanet

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. You understand and give your consent that your IP address and browser information might be processed by the security plugins installed on this site. By clicking “Accept”, you consent to the use of ALL the cookies.
Accept Read More

Privacy & Cookies Policy