How to install Python 3.8 in Ubuntu

Python is flexible and powerful open-source programming language. Python is popular language for its short syntax, data analysis, machine learning and artificial purpose.

In this tutorial, we will go through installing Python 3.8 in Ubuntu. However Python2 comes preinstalled in Ubuntu, but we will install latest version of Python 3.8 which is latest stable version of Python.

Prerequisite

You need to be logged as non-root user with sudo privilege to install packages in system.

There are many ways you can install Python package. Here are some simple ways you can install Python easily.

1. Install Python via PPA

You can simply add the third-party PPA repository to your Ubuntu software repository. This is the easy way to install Python package. This way you can also get update the package with apt package manager.

First open the Terminal software by using shortcut key CTRL+ALT+T or go to menu and open the Terminal.

Update the software repository index with below command:

sudo apt-get update

Install the common dependencies required for Python

sudo apt-get install software-properties-common

Now run the below command to add the third party deadsnakes PPA to your Ubuntu repository.

sudo add-apt-repository ppa:deadsnakes/ppa

Update the software repository index again and install the Python:

sudo apt-get update
sudo apt-get install python3.8

That's it. The latest Python is now installed. You can check the version by running the below command.

python3 --version

2. Installing from source code

Some hardcore users only want to install latest version of packages by building from the source code. In this way, you download the source code and build.

Open the Terminal and run the below commands as instructs.

First update the repository index and install the other required packages that will need to build the Python.

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

After you install the above packages, first go to ~/Downloads directory and download the source code from the Python official site. You can direct download the source code or from the wget command.

cd ~/Downloads
wget https://www.python.org/ftp/python/3.8.3/Python-3.8.3rc1.tgz

Now extract the source code

sudo tar xzf Python-3.8.3rc1.tgz

Go to the source code directory

cd  Python-3.8.3rc1

And build the package and install

./configure --enable-optimizations
sudo make
sudo make install

This way Python 3.8 will be installed to your Ubuntu system.

In this article, you have learned to install the latest version of Python by PPA as well as manually from the source code. I hope you had liked this article.

Tags: