pip-inspect
Inspect installed Python packages
TLDR
Inspect the current environment
Inspect and save output to a file
Inspect only locally installed packages (not global)
Inspect only user-installed packages
Inspect packages in a specific path
Inspect with verbose output (Note: the -v flag can be repeated to increase verbosity)
SYNOPSIS
pip inspect [--format <FORMAT>] [--path <PATH>] [--local-only] [--user-only] [--system] [--path-filter <PATH>]
PARAMETERS
--format <FORMAT>
Output format: json (default) or legacy-list.
--path <PATH>
Restrict inspection to the given path.
--local-only
Inspect only locally installed packages.
--user-only
Inspect only user site-packages.
--system
Inspect only system site-packages.
--path-filter <PATH>
Include packages matching path filter (repeatable).
DESCRIPTION
The pip inspect command provides a comprehensive, machine-readable inspection of the current Python environment. It generates a JSON report detailing installed distributions, their metadata, dependencies, requested packages, and environment details like Python version, platform, and installation paths.
Unlike pip list or pip freeze, which output simple text lists, pip inspect offers structured data ideal for automation, debugging dependency issues, or generating environment inventories. The report includes sections such as environment (paths, Python info), installed (packages with files, metadata, requires), requested (from setup_requires, etc.), and installer (pip version).
Use it to audit environments, detect conflicts, or integrate with tools like CI/CD pipelines. By default, it outputs to stdout in JSON format. Filters allow narrowing to specific paths, user/system sites, or local installs only.
CAVEATS
Requires pip ≥ 23.1. JSON output is verbose and not human-readable by default; use --format legacy-list for simpler view. Mutually exclusive path filters may error.
EXAMPLE OUTPUT SNIPPET
{
"environment": {
"python_version": "3.12.0",
"implementation_name": "cpython"
},
"installed": [{...}]
}
COMMON USE
Pipe to file: pip inspect > env.json for sharing or analysis.
HISTORY
Introduced in pip 23.1 (May 2023) to provide structured environment reports, expanding on pip list --format=json. Developed to aid dependency resolution and reproducibility.
SEE ALSO
pip(1), pip-list(1), pip-freeze(1), pip-show(1)


