How to install Python and Pip

Installing Python on Ubuntu

First, update your system:

sudo apt-get update

Install python prerequisite

sudo apt-get install build-essential libpq-dev libssl-dev openssl libffi-dev zlib1g-dev

Installing Pip3 and Python3

sudo apt-get install python-pip python3-pip python3-dev -y

Configuring Python 3 as default

python --version
pip --version

If the version is not Python3 or Pip3, we have to set the system to run Python3 and Pip3 by default. The very simple way is to use alias.

cd
sudo nano ~/.bashrc

Paste this at the top and save it.

alias python=python3

Then run this:

source ~/.bashrc
python --version

You should have Python version 3.

Configuring Pip 3 as default

Edit bashrc

cd
sudo nano ~/.bashrc

Paste this on the top:

alias pip='pip3'

Run this command to take effect:

source ~/.bashrc

Finally check your version:

pip --version

Leave a Comment

Your email address will not be published. Required fields are marked *