Usage
CLI
Basic inspection
Prints a formatted report of your current Python environment.
JSON output
Outputs a JSON object — useful for CI pipelines, scripting, or sharing in bug reports.
Include installed packages
Adds a full list of installed packages with versions to the output.
Skip pip version check
Skips the subprocess call to detect pip version, making the output slightly faster.
Run as a module
Combine flags
Import tracing
Trace where an import resolves
Shows:
- The resolved file path
- Module type (stdlib, third-party, local, builtin)
- Whether it's cached in
sys.modules - The sys.path search order
- Shadow warnings (if a local file shadows a real module)
Full search log
Shows every sys.path entry that was checked, not just the abbreviated version.
JSON trace output
Shadow detection
If a local file shadows a stdlib or installed package, you'll see:
Shadow scanning
Scan a project for shadows
Recursively scans for .py files that shadow stdlib or installed packages.
Scan stdlib only (faster)
Scan with JSON output
Scan a specific directory
Scan a single file
Smart exclusions — these directories are automatically skipped:
.venv,venv,env,.env__pycache__,.git,.tox,.mypy_cachenode_modules,dist,build,.eggs
Common non-module files are ignored: setup.py, conftest.py, manage.py, __init__.py.
Scan in Python code
from pywho import scan_path
from pathlib import Path
results = scan_path(Path("."))
for r in results:
print(f"[{r.severity.value.upper()}] {r.path} shadows {r.module_name}")
Exit codes
| Code | Meaning |
|---|---|
0 |
Success (no shadows for trace / scan) |
1 |
Shadows detected (for trace / scan) |
2 |
Error (e.g., path does not exist for scan) |
Python library
from pywho import inspect_environment
report = inspect_environment()
# Access fields directly
print(report.executable)
print(report.version)
print(report.venv.is_active)
print(report.venv.type)
print(report.package_manager)
# Skip package listing for speed
report = inspect_environment(include_packages=False)
# Serialize to dict (JSON-compatible)
data = report.to_dict()
Common workflows
Paste into a GitHub issue
Save environment snapshot in CI
Compare two environments
# On machine A
pywho --json > env-a.json
# On machine B
pywho --json > env-b.json
# Diff
diff env-a.json env-b.json