🌐
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 » ·
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.

🌐
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.
🌐
W3Schools
w3schools.com › python › python_modules.asp
Python Modules
There are several built-in modules in Python, which you can import whenever you like. ... There is a built-in function to list all the function names (or variable names) in a module.
🌐
Python documentation
docs.python.org › 3 › tutorial › modules.html
6. Modules — Python 3.14.3 documentation
>>> import builtins >>> dir(builtins) ['ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 'BlockingIOError', 'BrokenPipeError', 'BufferError', 'BytesWarning', 'ChildProcessError', 'ConnectionAbortedError', 'ConnectionError', 'ConnectionRefusedError', 'ConnectionResetError', 'DeprecationWarning', 'EOFError', 'Ellipsis', 'EnvironmentError', 'Exception', 'False', 'FileExistsError', 'FileNotFoundError', 'FloatingPointError', 'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError', 'ImportWarning', 'IndentationError', 'IndexError', 'InterruptedError', 'IsADirectoryError', 'K
🌐
Python
wiki.python.org › moin › UsefulModules
Useful Modules, Packages and Libraries - Python Wiki
Be warned that this list is subjective by its very nature - it is only intended as a helpful guide. It is not definitive in any way, nor should it discourage developers from developing their own modules. StandardLibraryBackports - modules that make later standard library functionality available in earlier version ... CTypes - A package for calling the functions of dlls/shared libraries. Now included with Python 2.5 and up.
🌐
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.
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-modules
Python Modules | DigitalOcean
August 4, 2022 - However, if you are looking for the Python modules available to you, then you can execute help('modules') command in Python shell to get the list of available modules.
Find elsewhere
🌐
Programiz
programiz.com › python-programming › modules
Python Modules (With Examples)
We can use dir in example module in the following way: print(dir(example)) ['__builtins__', '__cached__', '__doc__', '__file__', '__initializing__', '__loader__', '__name__', '__package__', 'add'] Here, we can see a sorted list of names (along with add). All other names that begin with an underscore are default Python attributes associated with the module (not user-defined).
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-modules
Python Modules - GeeksforGeeks
January 10, 2026 - You can view this list using sys.path. ... /home/guest/sandbox /usr/local/lib/python313.zip /usr/local/lib/python3.13 /usr/local/lib/python3.13/lib-dynload /usr/local/lib/python3.13/site-packages · Explanation: Python checks each path in order until it finds the module you’re trying to import.
🌐
CatsWhoCode
catswhocode.com › development & programming › python modules list: top packages & libraries 2026
Python Modules List: Top Packages & Libraries 2026
January 9, 2025 - You’ll learn about built-in modules ... both basic and advanced programming tasks. Protip: Use pip list or pip freeze to list all installed Python packages and modules....
🌐
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.
🌐
Tutorialspoint
tutorialspoint.com › python › python_modules.htm
Python - Modules
Python's standard library comes bundled with a large number of modules. They are called built-in modules. Most of these built-in modules are written in C (as the reference implementation of Python is in C), and pre-compiled into the library.
🌐
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.
🌐
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.
🌐
Sunscrapers
sunscrapers.com › blog › 30-built-in-python-modules-you-should-be-using-now
30 Built-In Python Modules You Should Be Using | Sunscrapers
December 19, 2023 - Modules and libraries help to speed up the dev process, saving plenty of time. Here are 30 built-in Python modules you better be using in your project.
🌐
Xah Lee
xahlee.info › python › standard_modules.html
Python: List Modules, List Loaded Modules
October 10, 2022 - To list all available modules in module path, type ... (on Microsoft Windows, pydoc is at C:/Python39/Tools/scripts/pydoc3.py. you might need to type the full path, or add it to your Microsoft Windows PATH environment variable.
🌐
PyPI
pypi.org
PyPI · The Python Package Index
The Python Package Index (PyPI) is a repository of software for the Python programming language.
🌐
WsCube Tech
wscubetech.com › resources › python › modules
Modules in Python: All Types With Examples
October 1, 2025 - Understand Python modules, its features, types, variables, and examples. Learn how to use modules in Python to enhance functionality and streamline coding.
🌐
Real Python
realpython.com › python-modules-packages
Python Modules and Packages – An Introduction – Real Python
March 21, 2024 - You might have expected (assuming you had any expectations at all) that Python would dive down into the package directory, find all the modules it could, and import them all. But as you can see, by default that is not what happens. Instead, Python follows this convention: if the __init__.py file in the package directory contains a list named __all__, it is taken to be a list of modules that should be imported when the statement from <package_name> import * is encountered.