Install python and pip on Ubuntu 16.04 (Xenial)
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
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
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
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
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
Note: if you have installed python3 directly you might get 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.