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
- id: C1 claim: The module provides utilities for the import system, in particular package support. source: S1 evidence: "utilities for the import system, in particular package support"
- id: C2 claim: walk_packages yields ModuleInfo for all modules recursively. source: S1 evidence: "Yields ModuleInfo for all modules recursively"
- id: C3 claim: get_data gets a resource from a package. source: S2 evidence: "Get a resource from a package"
- id: C4 claim: extend_path extends the search path for the modules which comprise a package. source: S2 evidence: "Extend the search path for the modules which comprise a package"
Sources
- [S1] pkgutil — Package extension utility. Python Software Foundation. https://docs.python.org/3/library/pkgutil.html . License: PSF License Version 2. Accessed 2026-11-24.
- [S2] pkgutil documentation (source). CPython. https://raw.githubusercontent.com/python/cpython/main/Doc/library/pkgutil.rst . License: PSF License Version 2. Accessed 2026-11-24.
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
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.},
}
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.
- python-pkgutil.schema.json (schema; CC-BY-4.0)
- python-pkgutil.table.json (table; CC-BY-4.0)
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.