The Pip, Pipenv, Anaconda Navigator, and Conda Package Managers can all be used to generate a simple list of installed Python packages, as well as JSON formatted lists.You can also use the ActiveState Platform’s command line interface (CLI), the State Tool to list all installed packages using a simple “state packages” command. For a complete list of all packages and dependencies (including OS-level and transitive dependencies, as well as shared libraries), you can use the Web GUI, which provides a full Bill of Materials view. Give it a try by signing up for a free ActiveState Platform account.
Before beginning this tutorial on getting a list of installed packages (including those located in site-packages, virtual environments, etc), it’s always a good practice to ensure you have an upto-date version of the Python programming language and the latest version of Pip, Anaconda Navigator and Conda in place.
List Installed Packages with Pip
There are a number of pip commands that you can use to get a list of package names and versions, including outdated packages. For example, both pip list and pip freeze will generate a list of installed packages, just with differently formatted results. Keep in mind that pip list will list ALL installed packages (no matter whether they were installed from the Python Package Index or Github, and no matter whether or not they were installed with the pip install command), while pip freeze will list only pip packages (ie., everything installed by whichever pip version you’re using).
Package Version ---------------------------------- ---------- absl-py 0.7.0
List Packages in a Console with Pip
To list all installed packages from a Python console using pip, you can utilize the following script:
>>> import pkg_resources installed_packages = pkg_resources.working_set installed_packages_list = sorted(["%s==%s" % (i.key, i.version) for i in installed_packages]) print(installed_packages_list)
['absl-py==0.7.0', 'adodbapi==220.127.116.11', 'alabaster==0.7.12', 'alembic==1.0.7', 'amqp==2.4.1', 'anyjson==0.3.3',
List Modules in a Console without Pip
To list all installed modules from a python console without pip, you can use the following command:
Note that there are some drawbacks to this approach, including:
- If there are a lot of installed packages, this method can take a long time to import each module before it can search that module’s path for sub-modules.
- Python modules that have code outside of an if __name__ == “__main__”: code block, and if user input is expected, may cause the code to enter an infinite loop or hang.
List Installed Packages with Pipenv
pipenv lock -r command can be used to generate output from a pipfile.lock file in a pipenv environment. All packages, including dependencies will be listed in the output. For example:
pipenv lock -r
-i https://pypi.org/simple certifi==2019.11.28 chardet==3.0.4 idna==2.9 requests==2.23.0 urllib3==1.25.8
List Installed Packages with Anaconda Navigator
To list installed packages in an Anaconda environment using Anaconda Navigator, do the following:
- Start the Anaconda Navigator application.
- Select Environments in the left column.
- A dropdown box at the center-top of the GUI should list installed packages. If not, then select Installed in the dropdown menu to list all packages.
List Installed Packages with Conda
conda list command can be used to list all packages in a conda environment:
# packages in environment at C:\Anaconda2_4.3.1: # _license 1.1 py27_1 alabaster 0.7.9 py27_0
Globally vs Locally Installed Packages
For information about generating a list of installed packages globally vs locally, refer to:
List Installed Packages with the ActiveState Platform
To view a list of installed Python packages in your currently active project using the ActiveState Platform, run the following command on the command line:
The output is a full list of installed packages in your current project:
matplotlib numpy pandas scikit-learn scipy
You can also obtain a complete software bill of materials view of all packages, dependencies, transitives dependencies (ie., dependencies of dependencies), OS-level dependencies and shared libraries (ie., OpenSSL) using the ActiveState Platform’s Web GUI:
The ActiveState Platform automatically builds all Python packages including linked C libraries from source code, and packages them for Windows, Linux and macOS. Because it does it all server-side, there’s no need to maintain local build environments.Try it out by signing up for a free ActiveState Platform account.
Frequently Asked Questions
How do I list all installed Python packages?
The simplest way for beginner Python developers to list all the Python packages they have installed (no matter how they were installed) is by running the following command using pip:
Learn more about how to install Python packages on Windows.
How can I list all pip-installed Python packages?
You can list all pip-installed packages by running the following command:
The output is an editable list of packages and their versions installed in the current environment.
How can I list Anaconda Python packages that are installed?
conda listThe output is a list of packages and their versions installed in the current environment.
How do I list Python packages installed in my virtualenv?
You can list all the packages installed in your virtualenv by running the following command from within the environment:
pip list --local
Note that virtualenv has been deprecated in Python 3.8 in favor of venv, which creates lightweight virtual environments optionally isolated from system site directories.