How to Download and Install Python Latest Version on Linux? - GeeksforGeeks

06 Oct, 2021
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,
Ubuntu
Linux Mint
Debian
openSUSE
CentOS
Fedora
and my favourite one, Arch Linux.
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

To install latest version from source code of Python follow below steps
First and foremost step is to open a browser and openhttps://www.python.org/downloads/source/
Underneath the Stable Releases find Download Gzipped source tarball (latest stable release as of now is Python 3.7.4).You can do all the above steps in a single command$ wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgzInstall Python 3.7.4 Latest Version on LinuxFor 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 terminaland 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 altinstallBingo..!! The latest version of Python language is installed on your Linux system. You can confirm it using below command.python --versionHow 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 = python3Now any code executed will automatically get python3 as default version.My Personal Notes
arrow_drop_upSave
You can do all the above steps in a single command
$ wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
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 terminaland 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
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.
how-to-install
python-utility
How To
Installation Guide
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Align Text in HTML?
How to filter object array based on attributes?
Java Tutorial
How to Install FFmpeg on Windows?
How to Install Anaconda on Windows?
Installation of Node.js on Linux
How to Install FFmpeg on Windows?
How to Install Anaconda on Windows?
How to Install Pygame on Windows ?
How to Install and Run Apache Kafka on Windows?