← All notes

Python pkgutil: utilities for the import system and packages

Answer: This module provides utilities for the import system, in particular package support.

Discovery helpers

ModuleInfo has a module_finder, a name, and ispkg.

iter_modules yields ModuleInfo for all submodules on a path, without recursing.

walk_packages yields ModuleInfo for all modules recursively on a path.

Package data and path extension

get_data can get a resource from a package and returns its contents, or None when the resource cannot be loaded.

extend_path is intended for a package's init module, to extend the search path for the modules which comprise a package.

extend_path is useful when a package is split across more than one directory on the search path.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, pkgutil — Package extension utility; CPython, pkgutil documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, pkgutil — Package extension utility; CPython, pkgutil documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation.

Cite this

Permanent ID: iil:note:wxvf0p4e

iinventedlight. 2026. "Python pkgutil: utilities for the import system and packages." iinventedlight Library, iil:note:wxvf0p4e, version of 2026-11-24. https://iinventedlight.com/library/notes/python-pkgutil/. License: CC-BY-4.0.

@misc{iil_note_wxvf0p4e,
  author = {{iinventedlight}},
  title = {{Python pkgutil: utilities for the import system and packages}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-24},
  url = {https://iinventedlight.com/library/notes/python-pkgutil/},
  note = {Permanent ID iil:note:wxvf0p4e. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/python-pkgutil.md.