Python is a free, open-source, and one of the most popular programming languages around the world. It is a versatile language and used to build all kinds of applications. It is the best choice for beginners due to its simple and easy to learn syntax.
The Python 3.9 version is the latest released with several improvements and security updates. In this post, we will show you how to install Python 3.9 via a third-party PPA and from the source on Ubuntu 20.04.
Table of Contents
Prerequisites
- An Ubuntu 20.04 VPS (we’ll be using our RoseHosting SSD 2 VPS plan)
- Access to the root user account (or access to an admin account with root privileges)
Step 1: Log in to the Server & Update the Server OS Packages
First, log in to your Ubuntu 20.04 server via SSH as the root user:
ssh root@IP_Address -p Port_number
You will need to replace ‘IP_Address’ and ‘Port_number’ with your server’s respective IP address and SSH port number. Additionally, replace ‘root’ with the username of the admin account if necessary.
Before starting, you have to make sure that all Ubuntu OS packages installed on the server are up to date. You can do this by running the following commands:
apt-get update -y apt-get upgrade -y
Step 2: Install Python 3.9 via PPA
In this section, we will show you how to install Python 3.9 via a third-party PPA.
First, you will need to install some dependencies required to install Python 3.9. You can install all of them with the following command:
apt-get install software-properties-common apt-transport-https gnupg2 -y
After installing all the dependencies, add the third-party PPA with the following command:
add-apt-repository ppa:deadsnakes/ppa
Once the repository is added, update the repository cache and install the Python 3.9 with the following command:
apt-get install python3.9 -y
Once the installation is completed, you can verify the installed version of Python with the following command:
python3.9 --version
You should get the following output:
Python 3.9.1
Step 3: Install Python 3.9 from Source
In this section, we will show you how to install the Python 3.9 from the source code. Before installing Python 3.9 from its source code, you will need to install some dependencies required to compile the Python.
You can install all dependencies with the following command:
apt-get install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev -y
Once all the dependencies are installed, download the latest version of Python source code with the following command:
wget https://www.python.org/ftp/python/3.9.1/Python-3.9.1.tgz
Once the download is completed, extract the downloaded file with the following command:
tar -xf Python-3.9.1.tgz
Next, change the directory to the extracted directory and configure the Python with the following command:
cd Python-3.9.1 ./configure --enable-optimizations
Next, install the Python 3.9 with the following command:
make altinstall
Once the installation has been completed, you can verify the installed version of Python using the following command:
python3.9 --version
You should get the following output:
Python 3.9.1
Of course, you can do none of this if you use one of our Python VPS Hosting services, in which case you can simply ask our expert Linux admins to setup this for you. They are available 24×7 and will take care of your request immediately and will make sure everything on your server is running smoothly.
PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.