Type help() in the interpreter

then

To get a list of available modules, keywords, or topics, type "modules",
"keywords", or "topics".  Each module also comes with a one-line summary
of what it does; to list the modules whose summaries contain a given word
such as "spam", type "modules spam".                                     

help> modules 
Answer from ghostdog74 on Stack Overflow
Top answer
1 of 6
112

Type help() in the interpreter

then

To get a list of available modules, keywords, or topics, type "modules",
"keywords", or "topics".  Each module also comes with a one-line summary
of what it does; to list the modules whose summaries contain a given word
such as "spam", type "modules spam".                                     

help> modules 
2 of 6
16

If you use ipython, which is an improved interactive Python shell (aka "REPL"), you can type import  (note the space at the end) followed by a press of the [TAB] key to get a list of importable modules.

As noted in this SO post, you will have to reset its hash of modules after installing (certain?) new ones. You likely don't need to worry about this yet.

If you don't use ipython, and you haven't tried it, it might be worth checking out. It's a lot better than the basic Python shell, or pretty much any other REPL I've used.

ipython Installation

If you're running linux, there is most likely an ipython package that you can install through your system management tools. Others will want to follow these instructions.

If your installation route requires you to use easy_install, you may want to consider instead using pip. pip is a bit smarter than easy_install and does a better job of keeping track of file locations. This is very helpful if you end up wanting to uninstall ipython.

Listing packages

Note that the above tip only lists modules. For a list which also includes packages —which contain modules— you can do from  + [TAB]. An explanation of the difference between packages and modules can be found in the Modules chapter of the helpful official Python tutorial.

#rtfm

As an added note, if you are very new to python, your time may be better spent browsing the standard library documentation than by just selecting modules based on their name. Python's core documentation is well-written and well-organized. The organizational groups —File and Directory Access, Data Types, etc.— used in the library documentation's table of contents are not readily apparent from the module/package names, and are not really used elsewhere, but serve as a valuable learning aid.

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

Discussions

python - How to list imported modules? - Stack Overflow
Sometimes (ex: with ipython --pylab) python interpreter is launched with predefined modules loaded. Question remains, for how to know the alias used o_O ... For those interested in displaying a list of all modules and their version numbers as a small measure of reproducibility, see the answers to this question stackoverflow.com/questions/20703975/… ... An approximation of getting all imports ... More on stackoverflow.com
🌐 stackoverflow.com
How do I get a list of locally installed Python modules? - Stack Overflow
Hidden in the documentation source directory in 2.5 is a small script that lists all available modules for a Python installation. ... the source code is really compact, so you can easy tinkering with it, for example to pass an exception list of buggy modules (don't try to import them) More on stackoverflow.com
🌐 stackoverflow.com
Is there a standard way to list names of Python modules in a package? - Stack Overflow
Is there a straightforward way to list the names of all modules in a package, without using __all__? For example, given this package: /testpkg /testpkg/__init__.py /testpkg/modulea.py /testpkg/mo... More on stackoverflow.com
🌐 stackoverflow.com
Easy way to list classes/functions defined in module without importing it?

Perhaps this will help

https://pypi.python.org/pypi/astdump/4.2

Extract information from Python modules without importing

Even with this I think you're going to have a tough time getting what you want, as things can be defined in a module dynamically such that they don't exist as "plain names" until the module is executed/imported

More on reddit.com
🌐 r/learnpython
13
5
January 1, 2015
🌐
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. 〔see Windows: Environment Variable Tutorial〕 ) ... Loaded module names is stored in the variable sys.modules. import sys import pprint # pretty print loaded modules pprint.pprint(sys.modules) # sample output # {'__main__': <module '__main__' from 'c:\\Users\\xah\\.emacs.d\\temp\\x20221010_0935_b29.py3'>, # '_abc': <module '_abc' (built-in)>, # '_codecs': <module '_codecs' (built-in)>, # ...
🌐
Python
docs.python.org › 3 › library › modules.html
Importing Modules — Python 3.14.3 documentation
The modules described in this chapter provide new ways to import other Python modules and hooks for customizing the import process. The full list of modules described in this chapter is: zipimport ...
🌐
Python
docs.python.org › 3 › py-modindex.html
Python Module Index — Python 3.14.3 documentation
Navigation · index · modules · Python » · 3.14.3 Documentation » · Python Module Index · Theme · Light · _ | 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
🌐
Python documentation
docs.python.org › 3 › tutorial › modules.html
6. Modules — Python 3.14.3 documentation
This could take a long time and importing sub-modules might have unwanted side-effects that should only happen when the sub-module is explicitly imported. The only solution is for the package author to provide an explicit index of the package. The import statement uses the following convention: if a package’s __init__.py code defines a list named __all__, it is taken to be the list of module names that should be imported when from package import * is encountered.
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-modules
Python Modules | DigitalOcean
August 4, 2022 - There are a lot of built-in modules in Python. Some of the important ones are - collections, datetime, logging, math, numpy, os, pip, sys, and time. You can execute help('modules') command in Python shell to get the list of available modules.
Find elsewhere
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.

🌐
W3Schools
w3schools.com › python › python_modules.asp
Python Modules
List all the defined names belonging to the platform module: import platform x = dir(platform) print(x) Try it Yourself » · Note: The dir() function can be used on all modules, also the ones you create yourself. You can choose to import only parts from a module, by using the from keyword. The module named mymodule has one function and one dictionary:
🌐
Real Python
realpython.com › python-all-attribute
Python's __all__: Packages, Modules, and Wildcard Imports – Real Python
March 4, 2024 - You’ve learned that these imports allow you to quickly get all the public objects from modules and packages. To control the process, Python has the __all__ variable, which you can define in your modules and packages as a list of objects that are available for wildcard imports.
🌐
Python
docs.python.org › 3 › library › modulefinder.html
modulefinder — Find modules used by a script
Loaded modules: _types: copyreg: _inverted_registry,_slotnames,__all__ re._compiler: isstring,_sre,_optimize_unicode _sre: re._constants: REPEAT_ONE,makedict,AT_END_LINE sys: re: __module__,finditer,_expand itertools: __main__: re,itertools,baconhameggs re._parser: _PATTERNENDERS,SRE_FLAG_UNICODE array: types: __module__,IntType,TypeType --------------------------------------------------- Modules not imported: guido.python.ham baconhameggs ... © Copyright 2001 Python Software Foundation. This page is licensed under the Python Software Foundation License Version 2. Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License. See History and License for more information.
🌐
Quora
quora.com › How-do-you-get-the-list-of-python-modules-on-your-computer
How to get the list of python modules on your computer - Quora
Answer: It’s very simple. Just follow these steps: * Open Python Shell. I have Windows, so I used Command Prompt. For Linux, use Terminal and accordingly for any other OS. * Type the command [code ]help(‘modules’)[/code] and press Enter. * You will get a list of all available Python modules ...
🌐
YouTube
youtube.com › watch
How to Get a List of Python Modules Correctly - YouTube
Tutorial on How to Get a List of Python Modules Correctly➖➖➖➖➖➖➖➖➖➖▶️ How to install PyCharm (one my favorite Python IDEs and the one I'm using in this Video...
Published   September 8, 2022
🌐
GitHub
gist.github.com › lrq3000 › 6175522
List recursively all imports of modules along with versions done from your Python application. Tested on Python 2.7. No dependencies except standard Python libs. · GitHub
List recursively all imports of modules along with versions done from your Python application. Tested on Python 2.7. No dependencies except standard Python libs. - pylistmodules.py
🌐
ActiveState
activestate.com › home › resources › quick read › how to list installed python packages
How to List Installed Python Packages - ActiveState
November 12, 2025 - 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 ...
🌐
TutorialsPoint
tutorialspoint.com › How-to-find-which-Python-modules-are-being-imported-from-a-package
How to find which Python modules are being imported from a package?
The list of imported Python modules are : ['__annotations__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__'] A number of helpful functions are offered by the inspect module to help in gathering data on active objects such modules, classes, methods, functions, tracebacks, frame objects, and code objects.
🌐
Python documentation
docs.python.org › 3 › reference › import.html
5. The import system — Python 3.14.3 documentation
Python includes a number of default finders and importers. The first one knows how to locate built-in modules, and the second knows how to locate frozen modules. A third default finder searches an import path for modules. The import path is a list of locations that may name file system paths or zip files.
🌐
Real Python
realpython.com › python-modules-packages
Python Modules and Packages – An Introduction – Real Python
March 21, 2024 - 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.