Open In App

How to Download and Install Python Latest Version on Linux?

Python is a widely-used general-purpose, high-level programming language. This article will serve as a complete tutorial on How to download and install Python latest version on Linux Operating Systems.
On every Linux system including following OS,

You will find Python already installed. You can check it using the following commands from the terminal



$ python --version

To check latest version of python 2.x.x :

$ python2 --version

To check latest version of python 3.x.x :



$ python3 --version


Clearly it won’t be the latest version of python. There can be multiple methods to install python on a linux base system and it all depends on your linux system.
For almost every Linux system, the following commands would work definitely.

$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt-get update
$ sudo apt-get install python3.7

Download and install Python Latest Version on Linux

To install latest version from source code of Python follow below steps

Download Python Latest Version from python.org
$ wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
Install Python 3.7.4 Latest Version on Linux

For installing Python successfully on Linux, Enter Following command to get the prerequisites and other source files

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev  libncursesw5-dev xz-utils tk-dev

Now we are all ready to unpack the file downloaded from the python official website’
Move to downloads directory using cd downloads in terminal
and then enter following commands

$ tar xvf Python-3.6.5.tgz
$ cd Python-3.6.5
$ ./configure --enable-optimizations --with-ensurepip=install
$ make -j 8
$ sudo make altinstall

Bingo..!! The latest version of Python language is installed on your Linux system. You can confirm it using below command.

python --version

How to set Python 3 as the default version in Linux?

One can easily install python using various techniques mentioned above in their Linux system. But how to set it as default? so that whenever you enter Python anywhere in the terminal it always executes python3. Here is the simple command from which you can set Python3 as default version.
Open your terminal and enter,

sudo alias python = python3

Now any code executed will automatically get python3 as default version.

Article Tags :