Python

How to Manage Python Packages with PIP

PIP is mainly used to install new Python packages/libraries/modules from the official PyPi package repository of Python. PIP can also upgrade the existing packages, install specific versions of Python packages, list the installed Python packages, and so on.

In this article, we will show you how to upgrade PIP to the latest version. We will also show you how to search for available Python packages in the PyPi package repository and how to install a Python package, install specific versions of a Python package, and upgrade the existing Python packages with PIP as well. Finally, we will show you how to list all the installed Python packages, see the information on specific Python packages, and uninstall the Python packages with PIP.

Topic of Contents:

  1. How to Check the Installed PIP Version
  2. How to Upgrade PIP to the Latest Version
  3. How to Search for Available Python Packages with PIP
  4. How to Install a Python Package with PIP
  5. How to See the Information on Installed Python Packages with PIP
  6. How to Install Specific Versions of a Python Package with PIP
  7. How to Upgrade the Installed Python Packages with PIP
  8. How to List the Installed Python Packages with PIP
  9. How to Uninstall the Python Packages with PIP
  10. Conclusion

How to Check the Installed PIP Version

To check the version of Python PIP that is installed on your computer, run the following command:

$ pip --version

PIP version 22.0.2 is installed on our computer as you can see in the following screenshot.  You may have a different version of PIP installed on your computer.

How to Upgrade PIP to the Latest Version

It’s a good idea to always keep Python PIP up to date. It’s very easy to upgrade PIP to the latest version.

To upgrade PIP to the latest version, run the following command:

$ pip install --upgrade pip

A newer version of PIP is being downloaded and installed. It takes a few seconds to complete.

At this point, PIP should be installed.

As you can see, Python PIP is upgraded to the latest version.

$ pip --version

How to Search for Available Python Packages with PIP

To search for available Python PIP packages, open a web browser and visit the official PyPi package repository.

Once the page loads, type in your search term in the “Search projects” section and press <Enter>.

We searched with the flask[1] keyword and the matched Python packages are listed[2].

Click on the Python package that you’re interested in to see more information.

A description of the selected Python package should be displayed[1]. You can read the “Project description” to find out what this package does and what you can use it for. You will also find the installation instructions for the selected Python package at the top of the page[2].

In the “Release history” section, you will find all the versions of that Python package that were released. You can install any one of the versions of the Python package that you want. We covered it in the How to Install Specific Versions of a Python Package with PIP section of this article.

How to Install a Python Package with PIP

To install a Flask Python package (let’s say) from the PyPi package repository, run the following command:

$ pip install Flask

The Flask Python package is being installed. It takes a few seconds to complete.

At this point, the Flask Python package alongside the required dependencies should be installed.

How to See the Information on Installed Python Packages with PIP

To see the information on an installed Python package which is Flask (let’s say), run the following command:

$ pip info Flask

The following information on the installed Python package should be printed:

Name: The name of the Python package.

Version: The version of the installed Python package.

Summary: A short description of what this package is for.

Home-page: The URL of the official website of the Python package.

Author: The name of the author of the Python package.

Author-email: The email address of the author of the Python package.

License: The license that the Python package is using.

Location: The path where the Python package is installed locally on your computer.

Requires: The list of packages that this Python package depends on.

Required-by: The list of packages that depend on this package to work.

How to Install Specific Versions of a Python Package with PIP

To install a specific version (2.1.0 let’s say) of the Flask Python package (let’s say), run the following command:

$ pip install --ignore-installed Flask==2.1.0

The Flask version 2.1.0 is being downloaded and installed. It takes a few seconds to complete.

At this point, Flask 2.1.0 should be installed.

As you can see, the Flask Python package version 2.1.0 is installed.

$ pip show Flask

How to Upgrade the Installed Python Packages with PIP

To check whether an up-to-date version of a Python package is available and to install the latest available version of the Flask Python package (let’s say), run the following command:

$ pip install --upgrade Flask

The Flask Python package should be upgraded to the latest version.

As you can see, the Flask Python package is upgraded from version 2.1.0 to 2.3.2.

How to List the Installed Python Packages with PIP

To list all the installed Python packages, run the following command:

$ pip list

A list of all the installed Python packages and the version number should be listed as you can see in the following screenshot:

How to Uninstall the Python Packages with PIP

To uninstall a Flask Python package (let’s say), run the following command:

$ pip uninstall Flask

To confirm the uninstallation action, press Y and then press <Enter>.

The Flask Python package should be uninstalled.

Conclusion

We showed you how to upgrade PIP to the latest version. We also showed you how to search for available Python packages in the PyPi package repository and how to install a Python package, install specific versions of a Python package, and upgrade the existing Python packages with PIP as well. Finally, we showed you how to list all the installed Python packages, see the information on specific Python packages, and uninstall the Python packages with PIP.

About the author

Shahriar Shovon

Freelancer & Linux System Administrator. Also loves Web API development with Node.js and JavaScript. I was born in Bangladesh. I am currently studying Electronics and Communication Engineering at Khulna University of Engineering & Technology (KUET), one of the demanding public engineering universities of Bangladesh.