Jump to content

How to Manage Python Packages with PIP


Linux Hint

Recommended Posts

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.

manage-python-packages-with-pip-02.png

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.

manage-python-packages-with-pip-04.png

At this point, PIP should be installed.

manage-python-packages-with-pip-05.png

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

$ pip --version

manage-python-packages-with-pip-06.png

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>.

manage-python-packages-with-pip-07.png

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.

manage-python-packages-with-pip-08.png

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].

manage-python-packages-with-pip-09.png

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.

manage-python-packages-with-pip-10.png

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.

manage-python-packages-with-pip-12.png

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

manage-python-packages-with-pip-13.png

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.

manage-python-packages-with-pip-15.png

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.

manage-python-packages-with-pip-17.png

At this point, Flask 2.1.0 should be installed.

manage-python-packages-with-pip-18.png

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

$ pip show Flask

manage-python-packages-with-pip-19.png

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.

manage-python-packages-with-pip-21.png

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

manage-python-packages-with-pip-22.png

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:

manage-python-packages-with-pip-24.png

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>.

manage-python-packages-with-pip-26.png

The Flask Python package should be uninstalled.

manage-python-packages-with-pip-27.png

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.

View the full article

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...