Skip to content

Instantly share code, notes, and snippets.

@timsonner
Created June 13, 2026 22:41
Show Gist options
  • Select an option

  • Save timsonner/9f936e35085fbb56f24aa703e1754bea to your computer and use it in GitHub Desktop.

Select an option

Save timsonner/9f936e35085fbb56f24aa703e1754bea to your computer and use it in GitHub Desktop.
Python module commands

Python module commands

1. Installed packages

Show what pip has installed in the current environment:

python3 -m pip list

2. Details / dependencies for an installed package

Show details for a specific package pip has installed:

python3 -m pip show <package name>

3. Available modules / get module help

Shows the modules Python can import in the current environment:

python3 -m pydoc modules

Get help for a specific module:

python3 -m pydoc modules <module name>

Start a pydoc web server

Browse module documentation in a browser.

  • python3 -m pydoc -n <hostname> starts a server with a chosen host name.
  • python3 -m pydoc -p <port> starts a server on a chosen port.
  • python3 -m pydoc -b starts a server on an unused port and opens the browser.
python3 -m pydoc -b

4. Where a module comes from

Shows the file path Python uses for a module. A path under your Python install directory usually means the standard library; a path under site-packages/ usually means a package installed with pip; a path in your project folder usually means a local module.

python3 -c "import <module name>; print(<module name>.__file__)"

Example:

python3 -c "import http; print(http.__file__)"

5. Python import search path

Shows where Python looks for modules:

python3 -c "import sys; print('\n'.join(sys.path))"

6. Package contents

Show contents of a package:

python3 -c "import <package name>, pkgutil; print('\n'.join(sorted(m.name for m in pkgutil.iter_modules(<package name>.__path__))))"

Example:

python3 -c "import http, pkgutil; print('\n'.join(sorted(m.name for m in pkgutil.iter_modules(http.__path__))))"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment