python,

List all installed packages in Python

Nov 13, 2022 · 1 min read · Post a comment

As with every other programming language you need to know who to manage your packages, modules and dependencies. You could always YOLO install every package globally, but as a best practice you should always have separate environments per project hence addressing many issues related to shared libraries such as dependency conflicts. So, first let’s see how to list all local and global packages in Python.

Prerequisites

  • Python
  • pip

Solution

pip global packages

List all Python packages and modules available:

pip list

or

pip freeze

To check a single package version, run:

pip list | grep <package_name>

or

pip freeze | grep <package_name>

pip local packages

List local Python packages installed by the current user running the following command:

pip list --user

or

pip freeze --user

To check a certain local package version, run:

pip list --user | grep <package_name>

or

pip freeze --user | grep <package_name>

pipenv

To list local Python packages using pipenv, first cd into your pipenv project and then run the following command:

pipenv graph
pipenv run pip list 
pipenv run pip freeze -all

Related: Python: pip list vs pip freeze (-all).

Conclusion

Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.