Javatpoint Logo
Javatpoint Logo

Install pip in Ubuntu

What is a pip?

Pip can be described as a tool to install the packages of Python. We can download, search, and install many packages using Python Package Index (short for PyPI) and other indexes of the package with pip. The pip is used to install and manage Python software packages. If installing any package, pip will first resolve the dependencies, identify if they are installed already, after that installs them if they aren't installed on our system. This process makes it convenient for installing and managing all software packages of Python, like those mentioned in the Python Package Index (short for PyPI).

Pip can also be described as an abstraction for "Pip Installs Packages". Pip is known as a package management system that implements with the command line. The uses of Ubuntu can easily install several packages using the Python Package Index by using pip. Also, it enables us to install more than one package and module of Python for our Python projects if we are software developers.

  • It is a tool of package installation that is used for getting packages through the PyPI and several repositories.
  • It can streamline the management and installation process of the package.
  • It is a package manager of multi-environment for Python projects which can assist in handling dependencies and libraries.
  • On Ubuntu Linux, the pip installation is a straightforward and quick procedure.
  • It links to an online public package repository which is known as Python Package Index.
  • Also, pip can be configured for connecting to various package repositories (remote or local), given that they adhere to Python Enhancement Proposal 503.
  • Most Python distributions come with pre-installed pip. The 2.7.9 and later versions of Python (on the series of python2), and the 3.4 and later versions of Python by default contain pip.

In this article, we will explain how we can install pip for Python 2 and Python 3 in the 20.04 version of Ubuntu. Also, we will walk through the installation basics and otherwise handle Python packages using pip.

History of Pip

In 2008, Pip was first announced as pyinstall by Ian Bicking (the virtualenv package creator) as a substitute to easy_install. Pip was selected as a fresh name from one of many recommendations that the creator got on his blog post.

The title is a recursive composition for "Pip Installs Packages" according to Ian Bicking himself.

The Python Packaging Authority (short for PyPA) was developed for taking over the virtualenv and Pip maintenance from Bicking which is led by Jannis Leidel, Brain Rosner, and Carl Meyer in 2011. With the 6.0 pip version publication, the naming process of the version was switched for having the version in the X.Y format and then removing the preceding 1 from the label of the version.

Before we start

Python is available in two versions including Python 3 and Python 2. Starting from the 20.04 version of Ubuntu, Python 3 is contained in the base system installation, and on the other side Python 2 is present for installation through the Universe repository.

Several users are motivated for switching to Python 3. When globally installing a module of Python, it is highly suggested to install the deb package of the module using the apt tool because they are tested to implement properly on all Ubuntu systems. The packages of Python 3 are pre-fixed with python3- and the packages of Python 2 are pre-fixed with python2-.

We should globally prefer pip for installing a module only when there's no deb package for that particular module. We should use pip only in a virtual environment. The virtual environments of Python permit us to install the modules of Python in a separated location for a particular project, instead of being globally installed. This way, we don't need to worry about impacting other projects of Python.

Prerequisites

Before we get began, we require an instance of the 20.04 version of Ubuntu with the sudo user. If we do not have anyone already, then we can readily use a fully-managed and high-performance cloud VPS at only 3.71 dollars.

Installing pip in Ubuntu 20.04

We can get the list of every compatible package using the official website of python packages (PyPI). Also, we can get support regarding the installation process with the help of this website.

For instance, if we wish to install a package such a "scrapy" which is the package applied for web scraping. Also, we can get the documentation of a package for our better understanding.

For installing the PIP file, we need to enter the command which is mentioned below:


Install pip in Ubuntu

This command will prompt us and ask for our permission whether we wish to install it or not (y/n), in which we need to click "y" for the installation process as displayed in the below screenshot:

The installed pip version can be recognized with the help of the command which is mentioned below:


Install pip in Ubuntu

Now, if we wish to know how we can apply the pip command and other available features, we can check them by entering the command in our terminal which is mentioned below:


Install pip in Ubuntu

Now, as we can check using the above screenshot, the first command is for installing the packages. So, let's take an instance of installing the python package, i.e., scrapy. We can do it by entering the command which is mentioned below:


Install pip in Ubuntu

Also, we can install other packages of our choice by pursuing the exact similar syntax.

We can see if a package is installed or not after the installation process by entering the command in our terminal which is mentioned below:


Install pip in Ubuntu

The above command will show us the list of every installed package and we might require to scroll down to check our installed packages.

Upgrade the packages using pip

We can use the following command for upgrading an already installed package to the current version:

Uninstalling the Python Packages

We can uninstall any old package that we have installed by entering the command which is mentioned below:


Install pip in Ubuntu

Installing pip for Python 2

For Python 2, the pip package is available in the universe repository. However, if we do not have it in our system, then we can install it with the help of the following command in the terminal:


Install pip in Ubuntu

For updating the packages list, we can enter the command which is mentioned below:


Install pip in Ubuntu

First, we will install the minimal package of Python 2:


Install pip in Ubuntu

For Python 2, the pip packages are not contained in the 20.04 version of Ubuntu. So, we require to apply the installer script of pip. The command is mentioned below:


Install pip in Ubuntu

Then, we need to run the Python script along with python2 for installing pip on our system. To do so, we can use the following command:


Install pip in Ubuntu

We can check the pip version after the installation process by entering the following command:


Install pip in Ubuntu

How to check installed packages with pip2 in Ubuntu

We can list every installed package using pip2 using the following command in the terminal:


Install pip in Ubuntu

We can see that the result is displaying the package installed using pip2:

Upgrading the packages with pip2 in Ubuntu

Also, we can upgrade the installed packages with the pip2 command. We can upgrade any package using the following syntax:

Uninstalling the packages with pip2 in Ubuntu

If you wish to uninstall any package from our Ubuntu system, we can use the option, i.e., 'uninstall' in the pip2 command. The syntax for uninstalling the packages using pip2 is as follows:

Uninstalling pip for Pyhton3 in Ubuntu 20.04

For python3, if we wish to uninstall a pip package, then we can do it by entering the command in our terminal which is mentioned below:


Install pip in Ubuntu

Conclusion

The codes of python are faster to run and have several modules to implement for enhancing the program's functionality. Python is one of the easiest to learn and simplified programming languages. In this article, we have learned how we can install the pip packages for python 3 and python 2 in the 20.04 version of the Ubuntu operating system. Also, we have learned how we can uninstall a pip and package.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA