How to Install Python on Linux / Ubuntu ?

If you have just now started looking into python, the first thing you need to do is install python on your development machine. If you are working on Windows, please check our another post “How to install Python on Windows”

This post helps you to install python on Ubuntu.

Installation of Python 2

To install default python version in your current Ubuntu distribution, just type below command,

$ sudo apt-get install python 

Once thats installed successfully, you can check where python is installed on your machine as,

$ which python
/usr/bin/python

And the version of Python can be checked as,

$ python --version
Python 2.7.17

We had installed Python in Ubuntu 18.04, where default python version installed is 2.7.17. In your Ubuntu you may see different version.

As seen in above the default python installation installs Python 2.

Installation of Python 3

Python 3 can be installed as,

$ sudo apt-get install python3
 $ which python3
/usr/bin/python3
$ python3 --version
Python 3.6.9

Installing latest Python Version

You can check the latest python version available from https://www.python.org/downloads/ . As of today the latest python version was 3.8 hence to install this latest python version, follow below steps,

$ sudo apt-get install software-properties-common 
$ sudo add-apt-repository ppa:deadsnakes/ppa 
$ sudo apt-get update 
$ sudo apt-get install python3.8 

Leave a Comment