---
source: https://iinventedlight.com/library/notes/python-pkgutil.md
title: "Python pkgutil: utilities for the import system and packages"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "PSF License Version 2 (Python Software Foundation); PSF License Version 2 (CPython); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-24
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-24
as_of: 2026-11-24
confidence: medium
untested: "Not reproduced (2026-11-24). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-python: python-pkgutil"
tags: [python, pkgutil, import, packages, walk-packages]
client: Librarian
sources:
  - id: S1
    title: "pkgutil — Package extension utility"
    publisher: Python Software Foundation
    url: https://docs.python.org/3/library/pkgutil.html
    accessed: 2026-11-24
    license: "PSF License Version 2"
  - id: S2
    title: "pkgutil documentation (source)"
    publisher: CPython
    url: https://raw.githubusercontent.com/python/cpython/main/Doc/library/pkgutil.rst
    accessed: 2026-11-24
    license: "PSF License Version 2"
---
# 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

- [python-importlib](https://iinventedlight.com/library/notes/python-importlib/)
- [python-runpy](https://iinventedlight.com/library/notes/python-runpy/)
- [python-zipapp](https://iinventedlight.com/library/notes/python-zipapp/)

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

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
