Install python and pip on Ubuntu 16.04 (Xenial)

Vishal Sharma
3 min readAug 30, 2018

--

“black and silver laptop computer on table” by Clément H on Unsplash

pip is a very simple package management system written in python and allow users to install and manage packages.

In this blog, we will learn how to install python and pip on Ubuntu 16.04 and check if it’s installed properly or not.

Pre-requisites:

  • Operating system: Ubuntu (16.04 Xenial) —

To check the version of Ubuntu Server, run following command

$ cat /etc/lsb-release
Ubuntu version check

Installation of python & pip:

python 2 installation:

To install python 2, run following commands:

$ sudo apt-get update$ sudo apt-get install python

To check if python is install properly, we’ll check the version of python:

$ sudo python --version or sudo python -V
Python version check

To install pip for python 2, run following commands:

$ sudo apt-get install python-pip

To check if pip is install properly, we’ll check the version of python:

$ sudo pip --version or sudo pip -V
pip version check

python 3 installation:

To install python 3, run following commands:

$ sudo apt-get update$ sudo apt-get install python3

To check if python is install properly, we’ll check the version of python:

$ sudo python3 --version or sudo python3 -V
python3 --version

To install pip for python 3, run following commands:

$ sudo apt-get install python3-pip

To check if pip is install properly, we’ll check the version of python:

$ sudo pip3 --version or sudo pip3 -V
pip3 — version

Note: if you have installed python3 directly you might get error.

python error

You can make a symbolic link to use python by following commands.

$ cd /usr/bin$ sudo ln -s ./python3 ./python

If you have installed both python2 and python3 together and want to use python3 as default than run following commands.

$ cd /usr/bin$ sudo rm python && ln -s ./python3 ./python

Congratulations, we have installed python on our system.

--

--

Vishal Sharma

IT Enthusiast, Professional, Novice Sportsperson and Fantasist of Better World. @byVishalSharma on Twitter.