grimp
Builds a queryable graph of the imports within one or more Python packages.
What it is and what it does
Grimp is a Python import graph builder that constructs a queryable representation of how modules within one or more packages import each other. It parses the installed package code and builds a directed graph where nodes are modules and edges represent import relationships. You use it to answer questions like 'what does this module import', 'what imports this module', and 'what is the shortest import chain between two modules'.
The package supports analyzing single packages, multiple packages together, and namespace packages. By default it excludes external dependencies, but you can include them to see the full import picture including third-party libraries. It returns import details including line numbers and the actual import statements, making it useful for code audits, refactoring, and understanding package architecture.
Use it for:
- Audit a package's internal structure to identify circular dependencies or tightly coupled modules.
- Find the shortest import path between two modules to understand coupling depth.
- Trace which modules depend on a specific internal API before refactoring it.
- Analyze namespace packages to understand how portions are distributed and imported.
- Generate import statistics for code quality reports or architecture documentation.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Grimp builds a queryable graph of Python package imports, letting you analyze module dependencies, find import chains, and trace which modules import what.
Yes. Grimp is actively maintained, has no known vulnerabilities, uses a permissive license, and solves a specific problem—understanding Python package import structure—that has no obvious built-in alternative. The medium install friction is standard for compiled packages and poses no real barrier. Install it if you need to analyze or audit module dependencies in Python code.
Install
grimp on PyPI
pip
pip install grimpuv
uv add grimppoetry
poetry add grimpInstalling grimp
Before you install
Medium install friction due to compiled wheels for multiple platforms and Python versions (3.10–3.14). Last release 42 days ago; repository is active with 129 stars and recent commits.
License in practice
BSD 2-Clause License is permissive; you may use, modify, and distribute grimp with minimal restrictions, provided you retain the license notice.
Quickstart
pip install grimp
import grimp
graph = grimp.build_graph('somepackage')
children = graph.find_children('somepackage.foo')
upstream = graph.find_upstream_modules('somepackage.foo')
Requires Python 3.10 or later; the target package must be installed before building its graph.
Verify before relying
- Performance characteristics on large codebases (number of modules or import depth limits).
- Whether the graph API supports filtering or excluding specific import types (e.g., conditional imports).
- Behavior when analyzing packages with circular imports or dynamic imports.
Package facts
| License | BSD 2-Clause License (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 42 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 14,311,547/month — #1,237 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: grimp-3.15-cp310-cp310-macosx_10_12_x86_64.whl; grimp-3.15-cp310-cp310-macosx_11_0_arm64.whl; grimp-3.15-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; grimp-3.15-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl; grimp-3.15-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl; grimp-3.15-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl; grimp-3.15-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl; grimp-3.15-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; grimp-3.15-cp310-cp310-musllinux_1_2_aarch64.whl; grimp-3.15-cp310-cp310-musllinux_1_2_armv7l.whl; grimp-3.15-cp310-cp310-musllinux_1_2_i686.whl; grimp-3.15-cp310-cp310-musllinux_1_2_x86_64.whl; grimp-3.15-cp310-cp310-win32.whl; grimp-3.15-cp310-cp310-win_amd64.whl; grimp-3.15-cp311-cp311-macosx_10_12_x86_64.whl; grimp-3.15-cp311-cp311-macosx_11_0_arm64.whl; grimp-3.15-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; grimp-3.15-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl; grimp-3.15-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl; grimp-3.15-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
modulegraphmodulegraph analyzes Python module dependencies…
permissive · top 15,000 on PyPI
apipkgapipkg lets you define a package's exported…
permissive · top 5,000 on PyPI
pydepsVisualizes Python module dependencies as graphs…
permissive · top 15,000 on PyPI
import-linterImport Linter enforces architectural…
permissive · top 5,000 on PyPI
pyan3Pyan3 performs static analysis on Python source…
copyleft · top 15,000 on PyPI
ipynbImports Jupyter Notebook (.ipynb) files as…
permissive · top 15,000 on PyPI
py-import-cyclesDetects import cycles in Python projects by…
permissive · top 15,000 on PyPI
modulegraph2Modulegraph2 builds and introspects a…
permissive · top 15,000 on PyPI
import-depsAnalyzes Python module imports statically using…
permissive · top 5,000 on PyPI
tachTach enforces module boundaries, dependency…
permissive · top 5,000 on PyPI