JSON output¶
Most pipx commands accept --output json to print a single machine-readable result envelope on stdout instead of
human-readable text. Selecting JSON suppresses pipx’s own progress messages and sends whatever pip or uv print while installing to stderr, so the envelope is the
only thing on stdout. When install moves to another Python because the package’s requires-python rules out the
default one, pipx says so on stderr as well.
Envelope¶
The envelope is a JSON object with these keys (serialized with sorted keys):
Key |
Value |
|---|---|
|
Envelope schema version, currently |
|
The command tokens as a list, for example |
|
|
|
The integer process exit code (see Exit codes). |
|
Command-specific payload object. Its fields depend on the command. |
|
List of error objects. Each has |
{
"pipx_result_version": "1",
"command": ["install"],
"status": "success",
"exit_code": 0,
"data": {},
"errors": []
}
Once the arguments parse, a failure on a JSON-enabled command still produces the envelope. That covers an invalid
environment variable such as PIPX_COOLDOWN, a --python that cannot be resolved, a path or URL where a package
name belongs, and --backend uv without a uv executable. The envelope has a status of "error" and a
single error whose code is pipx_error, and pipx exits 1. Only argument-parsing errors, such as an unknown
option or a missing argument, print plain text instead: the usage message goes to stderr and pipx exits 2.
Supported commands¶
--output json is available on: install, inject, uninject, expose, unexpose, pin,
unpin, upgrade, upgrade-all, upgrade-shared, uninstall, uninstall-all, reinstall,
reinstall-all, reset, health, repair, manifest lock, manifest sync, interpreter list,
interpreter prune, interpreter upgrade, cache dir, cache purge, and list --outdated.
The upgrade and upgrade-all payloads give each package result a suffix field. Its value is the recorded
suffix, or an empty string for a package installed without one.
For cache purge, data.removed lists the environments removed from the cache, including any moved to the trash.
An environment that remains after pipx attempts to delete it or move it to the trash has a cache_purge_failed error.
If any such error occurs, the status is "partial" when at least one environment was removed and "error"
otherwise.
--output json is unavailable on install-all, run, exec, runpip, ensurepath, environment,
completions, or help.
list is different¶
pipx list --output json without --outdated does not emit the result envelope; errors still use it. It prints
the installed-package snapshot that install-all reads back: an object with pipx_spec_version (currently
"0.1") and a venvs map of environment name to an object whose metadata key holds that environment’s metadata
(see On-disk metadata). pipx list --json is a legacy alias for the same snapshot. For a self-managed pipx on Unix,
the snapshot gives source_interpreter as null once the recorded interpreter no longer leads to the one its
environment runs on, for example a python3 from a bootstrap environment you removed, so install-all uses the
default Python there.
$ pipx list --output json > pipx.json
$ pipx install-all pipx.json
--json is a legacy alias only on list; every other command uses --output json.