{"id":9187,"date":"2020-11-19T06:50:46","date_gmt":"2020-11-19T11:50:46","guid":{"rendered":"http:\/\/local.brightwhiz\/?p=9187"},"modified":"2021-12-04T07:07:53","modified_gmt":"2021-12-04T07:07:53","slug":"install-python-3-9-ubuntu","status":"publish","type":"post","link":"http:\/\/local.brightwhiz\/install-python-3-9-ubuntu\/","title":{"rendered":"How To Install Python 3.9 on Ubuntu, Debian, or Linux Mint"},"content":{"rendered":"\n

This guide will show you how to install Python 3.9 which is the latest stable version as of this writing. it comes with several improvements and security updates. It also comes with some new modules, improved modules, and many other features.<\/p>\n\n\n\n

The target platforms for this guide are Ubuntu<\/a>, Debian, and Linux Mint distros. In this tutorial, we shall be using Ubuntu 18.04. Python<\/a> happens to be a very popular open-source<\/a>, high-level, object-oriented programming language.<\/p>\n\n\n\n

We will be showing you two ways on how to install Python 3.9, first using the PPA then we will switch over and show you how to install it from the source. You only need to pick one installation method.<\/p>\n\n\n\n

If you would like to install Python on Windows please follow this guide<\/a>.<\/p>\n\n\n\n

Prerequisites<\/h2>\n\n\n\n

Before you install Python 3.9, some required packages will need to be on your system. You can get your system ready by executing the following commands:<\/p>\n\n\n\n

$ sudo apt update\n$ sudo apt install software-properties-common<\/code><\/pre>\n\n\n\n

Install Python 3.9 Using apt-get<\/h2>\n\n\n\n

In your terminal on your system, execute the following command to add and configure deadsnakes<\/em> PPA to your system.<\/p>\n\n\n\n

$ sudo add-apt-repository ppa:deadsnakes\/ppa<\/code><\/pre>\n\n\n\n

Update the apt cache and install Python 3.9 on Ubuntu.<\/p>\n\n\n\n

$ sudo apt update\n$ sudo apt install python3.9<\/code><\/pre>\n\n\n\n

Once complete you can confirm the Python version number by executing the following:<\/p>\n\n\n\n

$python3.9 -V \n\nPython 3.9.0<\/code><\/pre>\n\n\n\n

Python 3.9 is now installed on your Linux system and ready for general purpose use.<\/p>\n\n\n\n

Install Python 3.9 Using Source Code<\/h2>\n\n\n\n

With the simplicity of installing Python 3.9 on Ubuntu, Debian, and Linux <\/a>Mint distros, there is very little sense as to why you would want to use the source code to get up and running. Therefore this method is only recommended for power users.<\/p>\n\n\n\n

To get started we need to install the essential packages needed to compile the source code. In you terminal execute the following:<\/p>\n\n\n\n

$ sudo apt install wget build-essential checkinstall \n$ sudo apt install libreadline-gplv2-dev libncursesw5-dev libssl-dev \\\n    libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev<\/code><\/pre>\n\n\n\n

Switch to a relevant directory and use wget<\/em> to download the Python 3.9 source code from the official download site as shown below.<\/p>\n\n\n\n

$ cd \/opt \n$ sudo wget https:\/\/www.python.org\/ftp\/python\/3.9.0\/Python-3.9.0.tgz<\/code><\/pre>\n\n\n\n

Extract the downloaded archive file using tar and configure the source for the installation as shown below:<\/p>\n\n\n\n

$ tar xzf Python-3.9.0.tgz\n$ cd Python-3.9.0\n$ sudo .\/configure --enable-optimizations<\/code><\/pre>\n\n\n\n

Execute make altinstall<\/strong><\/em> command to compile and install Python 3.9 on your Ubuntu system. make altinstall<\/strong><\/em> is used to prevent replacing the default python binary file which is located here \/usr\/bin\/python. Instead, it will create python3.9.<\/p>\n\n\n\n

$ sudo make altinstall<\/code><\/pre>\n\n\n\n

As always, verify the installed version once the process is complete.<\/p>\n\n\n\n

$ python3.9 -V \n\n$ Python 3.9.0<\/code><\/pre>\n\n\n\n

Conclusion<\/h2>\n\n\n\n

You may optionally remove the downloaded archive to free up space.<\/p>\n\n\n\n

$ sudo rm -f \/opt\/Python-3.9.0.tgz<\/code><\/pre>\n\n\n\n

You are now ready to use the latest version of Python together with the default version that came with your Ubuntu, Debian, or Linux Mint distros.<\/p>\n\n\n\n

Bonus Reading:<\/strong>
Here are some usage examples to test your installation.<\/p>\n\n\n\n