Top answer
1 of 16
1336
help('modules')

in a Python shell/prompt.

2 of 16
673

Solution

Do not use with pip > 10.0!

My 50 cents for getting a pip freeze-like list from a Python script:

import pip
installed_packages = pip.get_installed_distributions()
installed_packages_list = sorted(["%s==%s" % (i.key, i.version)
     for i in installed_packages])
print(installed_packages_list)

As a (too long) one liner:

sorted(["%s==%s" % (i.key, i.version) for i in pip.get_installed_distributions()])

Giving:

['behave==1.2.4', 'enum34==1.0', 'flask==0.10.1', 'itsdangerous==0.24',
 'jinja2==2.7.2', 'jsonschema==2.3.0', 'markupsafe==0.23', 'nose==1.3.3',
 'parse-type==0.3.4', 'parse==1.6.4', 'prettytable==0.7.2', 'requests==2.3.0',
 'six==1.6.1', 'vioozer-metadata==0.1', 'vioozer-users-server==0.1',
 'werkzeug==0.9.4']

Scope

This solution applies to the system scope or to a virtual environment scope, and covers packages installed by setuptools, pip and (god forbid) easy_install.

My use case

I added the result of this call to my Flask server, so when I call it with http://example.com/exampleServer/environment I get the list of packages installed on the server's virtualenv. It makes debugging a whole lot easier.

Caveats

I have noticed a strange behaviour of this technique - when the Python interpreter is invoked in the same directory as a setup.py file, it does not list the package installed by setup.py.

Steps to reproduce:

Create a virtual environment

 virtualenv test_env
New python executable in test_env/bin/python
Installing setuptools, pip...done.
$ source test_env/bin/activate
(test_env) $

Clone a Git repository with setup.py

(test_env) $ git clone https://github.com/behave/behave.git
Cloning into 'behave'...
remote: Reusing existing pack: 4350, done.
remote: Total 4350 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (4350/4350), 1.85 MiB | 418.00 KiB/s, done.
Resolving deltas: 100% (2388/2388), done.
Checking connectivity... done.

We have behave's setup.py in /tmp/behave:

(test_env) $ ls /tmp/behave/setup.py
    /tmp/behave/setup.py

Install the Python package from the Git repository

(test_env) $ cd /tmp/behave && pip install .
running install
...
Installed /private/tmp/test_env/lib/python2.7/site-packages/enum34-1.0-py2.7.egg
Finished processing dependencies for behave==1.2.5a1

If we run the aforementioned solution from /tmp

>>> import pip
>>> sorted(["%s==%s" % (i.key, i.version) for i in pip.get_installed_distributions()])
['behave==1.2.5a1', 'enum34==1.0', 'parse-type==0.3.4', 'parse==1.6.4', 'six==1.6.1']
>>> import os
>>> os.getcwd()
'/private/tmp'

If we run the aforementioned solution from /tmp/behave

>>> import pip
>>> sorted(["%s==%s" % (i.key, i.version) for i in pip.get_installed_distributions()])
['enum34==1.0', 'parse-type==0.3.4', 'parse==1.6.4', 'six==1.6.1']
>>> import os
>>> os.getcwd()
'/private/tmp/behave'

behave==1.2.5a1 is missing from the second example, because the working directory contains behave's setup.py file.

I could not find any reference to this issue in the documentation. Perhaps I shall open a bug for it.

🌐
Python
docs.python.org › 3 › py-modindex.html
Python Module Index — Python 3.14.3 documentation
modules | Python » · 3.14.3 Documentation » · Python Module Index · | Theme · Auto · Light · Dark | _ | a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s | t | u | v | w | x | z · « · index · modules | Python » · 3.14.3 Documentation » ·
Discussions

How to get a list of available imports (modules or libraries available in your device)?
That's not possible, or at least not easily possible. Python doesn't actually discover modules until you ask it for one using import. More on reddit.com
🌐 r/learnpython
6
1
June 6, 2020
Is there a way to see a list of all the python libraries that i have manually installed so far?
Open Command Prompt and type Python help('modules') OR type pip list Hope it helps. Thanks_ More on reddit.com
🌐 r/learnpython
19
17
February 27, 2019
🌐
Stack Abuse
stackabuse.com › bytes › how-to-list-installed-python-modules
How to List Installed Python Modules
September 12, 2023 - To sum up, Python provides a few ways to list all installed modules, whether you're working in a global or virtual environment. pip list and pip freeze are two commands that not only list the installed packages but also provide additional info, namely the version of the packages.
🌐
Medium
medium.com › @Doug-Creates › list-locally-installed-python-modules-5a8d70ef63a5
List Locally Installed Python Modules | by Doug Creates | Medium
March 25, 2024 - The script then parses this output, transforming it into a structured list of module names and their versions. This automated solution was integrated into their continuous integration pipeline, allowing for real-time monitoring and validation of the development environments. The result was a significant reduction in environment discrepancies and a smoother workflow for the development team. — Environment Specificity: Different Python environments (e.g., virtual environments) may have different sets of modules installed.
🌐
Reddit
reddit.com › r/learnpython › how to get a list of available imports (modules or libraries available in your device)?
r/learnpython on Reddit: How to get a list of available imports (modules or libraries available in your device)?
June 6, 2020 -

Some solutions are calling help('modules') and using a command line. But I want a list (the list structure) of all available imports. How can I do this?

Actually, what I’m trying to do is explore what libraries are available on Pythonista 3 (an iOS Python IDE). I want to get a list of modules excluding those from the standard library so I can print out each module’s docstring.

Find elsewhere
🌐
PyPI
pypi.org
PyPI · The Python Package Index
The Python Package Index (PyPI) is a repository of software for the Python programming language.
🌐
Wikipedia
en.wikipedia.org › wiki › Category:Python_(programming_language)_libraries
Category:Python (programming language) libraries - Wikipedia
Contains reusable Python modules. This category has only the following subcategory. Python (programming language) scientific libraries (38 P) The following 47 pages are in this category, out of 47 total. This list may not reflect recent changes.
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-list-installed-python-packages
How To List Installed Python Packages - GeeksforGeeks
January 29, 2026 - This method uses the pip command-line tool to display all packages installed in the current Python environment along with their versions. Use below command in your command prompt or terminal: ... Output: A table showing installed package names and their versions. ... This method lists installed packages in a format suitable for creating a requirements.txt file.
🌐
GitHub
gist.github.com › revathskumar › 1318667
list all installed modules in python · GitHub
list all installed modules in python. GitHub Gist: instantly share code, notes, and snippets.
🌐
ActiveState
activestate.com › home › resources › quick read › how to list installed python packages
How to List Installed Python Packages - ActiveState
November 12, 2025 - 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.
🌐
Python
docs.python.org › 3 › library › index.html
The Python Standard Library — Python 3.14.3 documentation
For Unix-like operating systems Python is normally provided as a collection of packages, so it may be necessary to use the packaging tools provided with the operating system to obtain some or all of the optional components. In addition to the standard library, there is an active collection of hundreds of thousands of components (from individual programs and modules to packages and entire application development frameworks), available from the Python Package Index.
🌐
pip
pip.pypa.io › en › stable › cli › pip_list
pip list - pip documentation v26.0.1
List outdated packages with column formatting. ... $ python -m pip list --outdated --format columns Package Version Latest Type ---------- ------- ------ ----- retry 0.8.1 0.9.1 wheel setuptools 20.6.7 21.0.0 wheel Windows
🌐
Geekflare
geekflare.com › development › 14 python libraries and modules every developer should know
14 Python Libraries and Modules Every Developer Should Know
December 29, 2024 - We will study the modules one by one according to their usage. Python has different types of collections to store the collection of data. For example, tuple, list, dict, etc.., are some of the built-in collections of Python.
🌐
OpenCV
opencv.org › home › news › top python libraries: a comprehensive guide
Top Python Libraries Every Beginner Should Learn & build projects
March 5, 2025 - In this blog, we’ll explore the top Python libraries every beginner should know, categorized by data science, deep learning, web development, and computer vision. Whether you’re working with data, building machine learning models, or developing web apps, this list will help you choose the right tools for your projects.
🌐
Edureka Community
edureka.co › home › community › categories › python › how can i get a list of locally installed python...
How can I get a list of locally installed Python modules | Edureka Community
November 26, 2020 - I would like to get a list of Python modules, which are in my Python installation (UNIX ... a list of Python modules installed in your computer?
🌐
TestMu AI Community
community.testmuai.com › ask a question
How to list installed Python modules locally? - Ask a Question - TestMu AI Community
November 12, 2024 - How do I get a python list modules that are installed on my computer? How can I retrieve a list of Python modules installed locally on my system?
🌐
Python
docs.python.org › 3 › library › modulefinder.html
modulefinder — Find modules used by a script
Print a report to standard output that lists the modules imported by the script and their paths, as well as modules that are missing or seem to be missing. ... Analyze the contents of the pathname file, which must contain Python code.
🌐
Amanxai
amanxai.com › home › all articles › all modules in python
All Modules in Python | Aman Kharwal
June 21, 2021 - Also, Read – Python Projects with Source Code. So this was the list of all the modules in the Python programming language that you should know as a Python developer. You can explore more about all these modules from here.
🌐
w3resource
w3resource.com › python-exercises › basic › python-basic-1-exercise-9.php
Python: Get a list of locally installed Python modules - w3resource
The above Python code uses the "pkg_resources" module to retrieve information about installed Python packages. It then creates a sorted list of strings representing each installed package along with its version and prints this information.