TIL: installed packages in Python – list, and show

Til Web Development

If your Python project has a very short list of required packages (in requirements, pipfile, etc), it’s easy to see all packages you have. But on large projects, the dependencies can run pretty long, not to mention the dependencies for the required packages. And what about learning more about those dependencies?

pip list

Will list all installed packages

pip show <package_name>

Will show information about installed packages and if you’re lucky, what other package requires that dependency

And, of course, pip -h will show all other pip options.

Example:

requirements.txt

Django>=3.1.0,<3.2.0
djangorestframework>=3.12.2,<3.13.0
psycopg2>=2.8.6,<2.9.0
Pillow>=8.1.0,<8.2.0

flake8>=3.8.4,<3.9.0

List my packages:

# pip list
Package             Version
------------------- -------
asgiref             3.3.1
Django              3.1.7
djangorestframework 3.12.2
flake8              3.8.4
mccabe              0.6.1
Pillow              8.1.0
pip                 21.0.1
psycopg2            2.8.6
pycodestyle         2.6.0
pyflakes            2.2.0
pytz                2021.1
setuptools          53.0.0
sqlparse            0.4.1
wheel               0.36.2

Show more about one package:

# pip show pyflakes
Name: pyflakes
Version: 2.2.0
Summary: passive checker of Python programs
Home-page: https://github.com/PyCQA/pyflakes
Author: A lot of people
Author-email: code-quality@python.org
License: MIT
Location: /usr/local/lib/python3.9/site-packages
Requires: 
Required-by: flake8

If you found this helpful, please share this article!

The post TIL: installed packages in Python - list, and show was originally published a flaviabastos.ca