How to List All the Packages Installed in Python

Here are 2 ways to list all the packages installed in Python:

(1) Run ‘pip list‘ in the command prompt or terminal:

pip list

Note that this command would only work if you already added Python to the Path.

To save this list to a text file:

pip freeze > installed_packages.txt

(2) Run a Python script to list all the installed packages:

import pkg_resources

installed_packages = [i.key for i in pkg_resources.working_set]

print(installed_packages)

Leave a Comment