Install Python 3.9.0 on ubuntu 20.04
Python is an interpreted, high-level and general-purpose programming language.Python programming language is being used in web development, Machine Learning applications, along with all cutting edge technology in software industry. Python is a popular choice for beginners and experienced developers.
At the time of writing, Python’s latest stable release is 3.9.0. As of now, the default Python version in Ubuntu 20.04 LTS is 3.8.5.
In this article we will show you how to install Python 3.9 on Ubuntu 20.04 LTS.
Also Read -> How to Install Apache Tomcat 9 on Ubuntu 20 04
Install python 3.9 using apt
First we will update package list and install dependencies.
sudo apt update
sudo apt install software-properties-common
Now Add deadsnakes PPA repository to source list.
sudo add-apt-repository ppa:deadsnakes/ppa
when prompted press Enter to add it.
Then update apt cache and install python 3.9
sudo apt update
sudo apt install python3.9
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libpython3.9-minimal libpython3.9-stdlib python3.9-minimal
Suggested packages:
python3.9-venv python3.9-doc binutils binfmt-support
The following NEW packages will be installed:
libpython3.9-minimal libpython3.9-stdlib python3.9 python3.9-minimal
0 upgraded, 4 newly installed, 0 to remove and 128 not upgraded.
Need to get 4,952 kB of archives.
After this operation, 19.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Also Read -> How to Install Atom Text Editor on Ubuntu 20 04
once installation is completed,you can check the python version with the following command.
python3.9 --version
output:
root@ubuntu20:~# python3.9 -V
Python 3.9.0+
Also Read -> How to Install PHP 8 on Ubuntu 20 04
Install Python 3.9.x from source code
First we will install the required dependencies to build python.
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
download source code
you can download the latest source code from download page.
once it is downloaded,extract it using tar command.
wget https://www.python.org/ftp/python/3.9.1/Python-3.9.1.tgz
tar -xvzf Python-3.9.1.tgz
now go to Python source directory and execute the configure script.
cd Python-3.9.1
./configure --enable-optimizations
start the Python 3.9 build process using make command
make -j 4
For faster build time, modify -j to correspond to number of cores in your processor.you can find that by typing nproc and replace number.
Once the build process is complete, install the Python binaries.
sudo make altinstall
Make a note that do not use the standard "make install" as it will overwrite the default system with python3 binary.
Then python 3.9 has been installed and ready to be used.verify it using the following command.
python3.9 -V
output:
Python 3.9.1
That's it. Now you have learned installing Python 3.9 using Apt and source code on ubuntu 20.04 Lts system.
Also Read -> How to Install Apache Maven on Ubuntu 20 04