Link Search Menu Expand Document

Pip and its Uses in Python

What is Pip?

Python has a wide range of packages which consist of files that are essential for the working of a module. Python modules are the code libraries that the users import while programming to utilize certain functions for efficient coding. Pip is the primary manager for such packages and modules needed for the program. It allows the installation and management of various additional libraries and dependencies that are not usually available in the standard python library. In some versions of Python, pip is pre-installed, but in others, the users have to install it later manually. The users can verify the installed version of a pip by using the following piece of code:

pip - - version

Primary Syntax

The main syntax of the pip command is:

pip <pip arguments>

Pip Usage

These are some of the uses of pip in Python language:

Package Installation Using pip

In Python, pip is a tool to install packages for later usage in a program. It works by connecting with an online repository that includes public and private packages and is known as the Python Package Index, which is also known as PyPI. It also includes many development frameworks, along with tools and libraries. Pip utilizes a command-line interface by maintaining it user-friendly through easy scripting. It allows the user to install the package required by the user by using the package name. Once the user has navigated it to Python’s script directory, he can write the following command to install any package:

pip install package-name

Uninstalling a Package

Similarly, the users can uninstall some specific functions by using the following piece of code:

pip uninstall package-name

Listing Installed Packages

Moreover, the pip command provides information to the users on all the installed packages in the system. To verify this following command is executed on the command-line interface:

pip show requests

Listing all Available Packages

Additionally, the users can view all the available packages in a particular environment by writing the script to list as below:

pip list

Installing a Package with specific Version

Furthermore, pip allows the installation of a package with a specific python version by using the following command:

pip${version} install package-name

Allowing HTTP requests in Python

Another essential thing about pip is that it supports HTTP requests by using a library from PyPI, which is called requests. Sample code for allowing HTTP requests in Python is the following:

pip install requests

Upgrading pip

Since there is always up-gradation happening in such tools and improved versions are provided, pip can also be upgraded from the previous to the new version by using the following command whenever there is a need to upgrade the version:

python -m pip install - - upgrade pip

Install multiple packages using a Requirement File

Moreover, the pip command can quite interestingly read the package name from a specified text file to install or install them. For instance, a file named “name.txt” contains:


When the user writes the command given below, it installs all the packages and their dependencies as well. The script below is the same as the install script above with the addition of “–r”. The “-r” tells the pip that the name.txt is a “requirement file”, not a package name.

Pip install –r name.txt

Search packages

Finally, the users can search packages in the command prompt using the search command with pip. Below is the script to perform the search:

Pip search numpy

Other useful articles:

Back to top

© , Learn Python 101 — All Rights Reserved - Terms of Use - Privacy Policy