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, 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
This is an easy and quick way to install python 3.9 on Ubuntu using the apt package manager.
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 by issuing the following command:
sudo apt install python3.9
Type in the following to check that the installation was completed successfully:
That sums it up well. Python 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
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:
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
--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 is now installed and ready for usage. To confirm, type:
The following Python version should be shown in the output:
Python 3.9 is not included in the normal Ubuntu 20.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..