Skip to content
Related Articles

Related Articles

Python PIP

View Discussion
Improve Article
Save Article
  • Last Updated : 25 Jul, 2022

In this article, we will discuss what is pip, and how to install, upgrade and uninstall packages using pip. So before starting using let us understand what is a pip?

What is a pip?

Python pip is the package manager for Python packages. We can use pip to install packages that do not come with Python. The basic syntax of pip commands in command prompt is: 

pip 'arguments'

How to install pip?

Python pip comes pre-installed on 3.4 or older versions of Python. To check whether pip is installed or not type the below command in the terminal.

pip --version

This command will tell the version of the pip if pip is already installed in the system.

check installation of pip

If you do not have pip installed on your system refer to the below articles.

How to install Package with Pip

We can install additional packages by using the Python pip install command. Let’s suppose we want to install the Numpy using pip. We can do it using the below command.

Syntax: 

pip install numpy

Example 1: When the required package is not installed. 

Example 2: When the required package is already installed. 

Specifying Package Version

We can also install the package of a specific version by using the below command.

Syntax: 

pip install package_name==version

This will install the package with the specified version

Display package information using pip

We can use the Python pip show command to display the details of a particular package. 

Syntax: 

pip show numpy

Example: 

Note: 

  • Requires column shows the dependencies required by the NumPy package
  • Required by shows the packages that require NumPy

Get a list of locally installed Python modules

The Python pip list command displays a list of packages installed in the system. 

Syntax: 

pip list

Example: 

Uninstall packages with pip

The Python pip uninstall command uninstalls a particular existing package. 

Syntax: 

pip uninstall numpy

Example: 

Note: The pip uninstall command does not uninstall the package dependencies. If you want to remove the dependencies as well then you can see the dependencies using the pip show command and remove each package manually.

Search packages with pip

We can search for a particular existing package using the Python pip search command. 

Syntax: 

pip search numpy

Example: 

Using requirement files with pip

Let’s suppose you want more than one package then instead of installing each package manually, you can install all the modules in a single go. This can be done by creating a requirements.txt file. Let’s suppose the requirements.txt file looks like this:

 

Syntax: 

pip install -r requirements.txt

Example: 

Listing additional packages with pip

The Python pip freeze command is used to list packages that don’t come pre-installed with Python. 

Syntax: 

pip freeze

Example: 

 

Listing Outdated Packages with pip

Python pip list –outdated command is used to list all the packages that are outdated. This command cross-checks the installed package information with the pip repository.

Syntax:

pip list --outdated

Example:

Listing Outdated Packages

Upgrading packages with pip

Python pip install –user –upgrade is used to update a package.

Syntax:

pip install --user --upgrade package_name

Example:

upgrading packaged with pipupgrading packaged with pip

We can also upgrade any package to a specific version using the below command.

pip install --user --upgrade package_name==version

Downgrading packages with pip

the Python pip install –user command is used to downgrade a package to the specific version.

Syntax:

pip install --user package_name==version

Example:

downgrade package python pip

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!