How To Install Pip in Ubuntu Linux

Pip is a popular package installer for Python. It allows you to easily install, upgrade and uninstall python packages. Pip is not installed in Ubuntu by default. In this article, we will look at how to install pip in Ubuntu.


How To Install Pip in Ubuntu Linux

Here are the steps to install pip in Ubuntu Linux.


1. Update Ubuntu package list

Open terminal and run the following command to update package list in Ubuntu.

$ sudo apt update

Also read : How to Enable Gzip in NGINX


2. Install Pip in Ubuntu

If you don’t know your python version, run the following command.

$ python -v
2.7.11

Depending on your python version, run the following command to install pip in Ubuntu.

Python 3

$ sudo apt install python3-pip

Run the following command to check pip version

$ sudo pip3 -v
9.0.1

Also read : How to Redirect Subfolder to Root in Apache


Python 2

$ sudo apt install python-pip

Run the following command to check pip version

$ sudo pip -v
9.0.1

Please note : You need to use pip3 command for Python 3.x and pip command for Python 2.x.

That’s it. pip will be installed on your system.

Also read : How to Install WordPress in NGINX


Useful pip commands

Here are some useful pip commands to help you get started with Pip.

Here is the command to get specific options for each pip command

$ sudo pip3 <command> --help

For example, here is the command to list all available options for pip install command

$ sudo pip3 install --help


Install package with pip

Here is the command to install python package using pip

$ sudo pip3 install package_name

For example, here is the command to install Django

$ sudo pip3 install django

Here is the command to install a specific version (3.1.7) of Django

$ sudo pip3 install django==3.1.7

Also read : How to Block User Agent in Apache


Uninstall package with pip

Here is the pip command to uninstall a package

$ sudo pip3 uninstall package_name

For example, here is the command to uninstall django

$ sudo pip3 uninstall django


Upgrade package with pip

Here is the command to upgrade package

$ sudo pip3 --upgrade package_name

For example, here is the command to upgrade django

$ sudo pip3 --upgrade django

Here is the command to upgrade django to a specific version

$ sudo pip3 --upgrade django==3.1.7

Also read : How to Change Root Password in Ubuntu


List packages installed with pip

Here is the command to list all installed packages using pip.

$ sudo pip3 list

We hope this tutorial helps you get started with pip python package installer.

Leave a Reply

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