pywho
One command to explain your Python environment, trace imports, and detect shadows.
Ever asked "Which Python am I running? Why did import X load that file? Do I have any files shadowing real modules? Why does this work on your machine and not on mine?" — pywho answers all of it instantly.
Quick Reference
| Command | Description |
|---|---|
pywho |
Show a full report of your Python environment |
pywho --json |
Output environment report as JSON |
pywho --packages |
Include all installed packages in the report |
pywho --no-pip |
Skip pip version detection |
pywho trace <module> |
Trace where an import resolves and show search order |
pywho trace <module> --verbose |
Trace with full sys.path search log |
pywho trace <module> --json |
Trace output as JSON |
pywho scan . |
Scan project for files that shadow stdlib/installed packages |
pywho scan . --no-installed |
Scan against stdlib only (skip installed packages) |
pywho scan . --json |
Scan output as JSON |
pywho doctor |
Check the environment for the usual setup problems |
pywho diff a.json b.json |
Compare two environment snapshots |
pywho --python <path> ... |
Run any command inside another interpreter or virtual environment |
python -m pywho |
Run as a Python module |
Table of Contents
Getting Started
pip install pywho
Or with uv:
uv add --dev pywho
For one-off usage without installing anything into the project:
uvx pywho --python .venv
Note:
uvx pywho,pipx run pywhoanduv run --with pywho pywhoall run pywho inside a separate, temporary environment, and on their own they describe that environment, not your project. Useuvxorpipx runtogether with--python. See Inspecting Another Interpreter.
Why pywho?
- "Works on my machine" is the #1 debugging friction in Python. pywho kills it with one command.
- Paste the output into a GitHub issue, Slack message, or Stack Overflow question. Done.
- Zero dependencies. Pure stdlib. Works everywhere Python runs.
- Cross-platform. Linux, macOS, Windows. Python 3.10+.
Usage
Environment Inspection
pywho
pywho - Python Environment Inspector
==============================================
Interpreter
Executable: /Users/dev/myproject/.venv/bin/python3
Version: 3.12.3 (CPython)
Compiler: Clang 15.0.0 (clang-1500.3.9.4)
Architecture: 64-bit
Build: main, Apr 9 2024, 08:09:14
Platform
System: Darwin 24.1.0
Machine: arm64
Virtual Environment
Active: Yes
Type: uv
Path: /Users/dev/myproject/.venv
Prompt: myproject
Paths
Prefix: /Users/dev/myproject/.venv
Base Prefix: /opt/homebrew/Cellar/python@3.12/...
Site-packages: /Users/dev/myproject/.venv/lib/python3.12/site-packages
Package Manager
Detected: uv
pip version: 24.0
sys.path
[0] /Users/dev/myproject/.venv/bin
[1] /opt/homebrew/.../python312.zip
[2] /opt/homebrew/.../python3.12
...
JSON output (for CI, scripts, sharing)
pywho --json
Include installed packages
pywho --packages
Skip pip version check
pywho --no-pip
Run as module
python -m pywho
Import Tracing
Trace exactly where an import resolves and why:
pywho trace requests
Import Resolution: requests
===========================
Resolved to: /Users/dev/myproject/.venv/lib/python3.12/site-packages/requests/__init__.py
Module type: third-party (package)
Package: requests 2.32.3 (installed by uv; required by httpie)
Search order:
[0] /Users/dev/myproject -> not found
[2] /opt/homebrew/.../python3.12 -> not found
[4] /Users/dev/myproject/.venv/lib/python3.12/site-packages
-> FOUND /Users/dev/myproject/.venv/lib/python3.12/site-packages/requests/__init__.py
What the report tells you:
- Resolved to is the file a fresh program started in this folder would import. The modules pywho itself has loaded do not decide the answer.
- Package names the installed distribution that put the file there, even when the names differ (
import yamlcomes fromPyYAML), the tool that installed it, and the installed packages that require it. - Search order numbers are the real positions in
sys.path. The current folder is searched first, as it is when you run a script from it.
A dotted name such as pywho trace requests.adapters imports the parent package (requests) first, exactly as Python would. If that import fails, the error is shown instead of a crash.
Full search log
pywho trace json --verbose
JSON trace output
pywho trace requests --json
Shadow detection (single module)
$ pywho trace requests
WARNING: '/Users/dev/myproject/requests.py' shadows installed package at '/Users/dev/myproject/.venv/lib/python3.12/site-packages/requests/__init__.py'
Shadow Scanning
Scan an entire project for files that shadow stdlib or installed packages:
$ pywho scan .
Found 2 shadow(s)
2 HIGH (stdlib)
[HIGH] json.py
shadows stdlib module 'json'
[HIGH] math.py
shadows stdlib module 'math'
Scan with JSON output
pywho scan . --json
Scan stdlib only (skip installed packages)
pywho scan . --no-installed
Smart exclusions — these directories are automatically skipped: .venv, __pycache__, node_modules, dist, build, .git, and more.
"Installed" means importable from a site-packages folder. A project file never counts as shadowing itself, so the result is the same whether you run pywho scan ., python -m pywho scan ., or have the project installed in editable mode.
Health Checks
pywho doctor looks for the usual reasons an environment misbehaves and tells you which one applies:
$ pywho doctor
pywho doctor
============
[ OK ] The activated virtual environment is in use.
[FAIL] pip and python on PATH belong to different environments.
python -> /Users/dev/myproject/.venv/bin/python (Python 3.12)
pip -> /opt/homebrew/bin/pip (Python 3.11)
pip installs into -> /opt/homebrew/lib/python3.11/site-packages
[WARN] Environment variables change where every Python looks for modules.
PYTHONPATH=/Users/dev/old-libs
[ OK ] Every sys.path entry exists.
[ OK ] No duplicate or broken packages.
[ OK ] No .pth file points to a missing folder.
1 problem, 1 warning
| Check | What it catches |
|---|---|
| Activated environment | VIRTUAL_ENV points to one environment while another Python is running |
python and pip on PATH |
pip install puts packages where python never looks |
| Environment variables | PYTHONPATH or PYTHONHOME silently changing every Python |
sys.path |
Entries that do not exist |
| Packages | The same package installed in two versions, or a folder left without metadata by a failed uninstall |
.pth files |
Files pointing to a folder that is gone (a moved editable install) |
| Externally managed | A system Python that refuses pip install (PEP 668) |
Exit code is 1 when a check fails, 0 otherwise. Warnings are advice and do not change the exit code. Use pywho doctor --json in scripts.
Comparing Environments
Save a snapshot on each machine, then let pywho show what differs:
# On each machine
pywho --json --packages > env.json
# Anywhere
pywho diff mine.json theirs.json
pywho diff
==========
A: mine.json
B: theirs.json
Environment
interpreter.version: 3.12.3 -> 3.11.9
platform.system: Darwin -> Linux
Packages
Only in A (1)
idna 3.7
Different version (1)
requests 2.31.0 -> 2.32.3
Folder paths are left out of the comparison: they differ on every machine and would hide what matters. Exit code is 1 when the snapshots differ, 0 when they match. Snapshots made without --packages are compared without their package lists.
Inspecting Another Interpreter
Every command accepts --python. pywho then runs inside that interpreter, which does not need pywho installed:
pywho --python .venv # a virtual environment folder
pywho --python /usr/bin/python3.11 # an interpreter
pywho --python python3 doctor # a command on PATH
pywho --python ../other-project/.venv trace requests
This is what makes a single global install useful for every project:
uvx pywho --python .venv
pipx run pywho --python .venv doctor
The target must be Python 3.10 or newer. Nothing from pywho's own environment leaks into the report.
Python API
Environment inspection
from pywho import inspect_environment
report = inspect_environment()
print(report.executable) # /usr/bin/python3
print(report.venv.is_active) # True
print(report.venv.type) # "uv"
print(report.package_manager) # "uv"
# Get JSON-serializable dict
data = report.to_dict()
Import tracing
from pywho import trace_import
trace = trace_import("requests")
print(trace.resolved_path) # /path/to/requests/__init__.py
print(trace.module_type) # ModuleType.THIRD_PARTY
print(trace.provided_by) # [ProvidingPackage(name='requests', version='2.32.3', ...)]
print(trace.shadows) # [] (empty = no shadows)
if trace.shadows:
for s in trace.shadows:
print(f"WARNING: {s.description}")
Shadow scanning
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}")
Health checks
from pywho import run_doctor
for check in run_doctor():
print(check.status.value, check.summary)
Comparing environments
from pywho import diff_reports, inspect_environment
from pywho.differ import load_snapshot
diff = diff_reports(inspect_environment().to_dict(), load_snapshot("theirs.json"))
for package in diff.packages:
print(package.name, package.a, "->", package.b)
What It Detects
Interpreters
- CPython, PyPy, and other implementations
- Version, compiler, architecture (32/64-bit)
- Build date
Virtual environments
| Type | Detection method |
|---|---|
| venv | sys.prefix != sys.base_prefix |
| virtualenv | virtualenv = in pyvenv.cfg |
| uv | uv = in pyvenv.cfg |
| conda | conda-meta folder in sys.prefix |
| poetry | POETRY_ACTIVE env var, inside a virtual environment |
| pipenv | PIPENV_ACTIVE env var, inside a virtual environment |
A virtual environment created on top of conda is reported as the virtual environment it is, not as conda.
Package managers
Detects: pip, uv, conda, poetry, pipenv, pyenv
Paths
sys.prefix,sys.base_prefix,sys.exec_prefix- All
site-packagesdirectories - Full
sys.pathwith index numbers
Packages
With --packages: lists all installed packages with versions and locations.
Import shadows
- Single-module detection via
pywho trace - Project-wide scanning via
pywho scan - Severity levels: HIGH (stdlib) and MEDIUM (installed)
Environment problems
- Activated environment that is not the running Python
pipandpythonfrom different environmentsPYTHONPATH/PYTHONHOMEoverrides- Packages installed in two versions and broken package folders
- Stale
.pthfiles and missingsys.pathentries
Use Cases
| Scenario | Command |
|---|---|
| Debug "works on my machine" | pywho --json --packages > env.json, then pywho diff mine.json theirs.json |
| Verify onboarding setup | pywho doctor |
| CI environment snapshots | pywho --json --packages > env.json |
| Fail CI on a broken environment | pywho doctor (exit code 1 on a problem) |
| Find why an import is wrong | pywho trace <module> |
| Find which package provides a module | pywho trace <module> |
| Audit project for shadows | pywho scan . |
| Inspect a project from a global install | pywho --python .venv |
| Ask users for their env | "Please run pywho" |
Platforms
| Platform | Status |
|---|---|
| Linux | ✅ Supported |
| macOS | ✅ Supported |
| Windows | ✅ Supported |
| Python | Status |
|---|---|
| 3.10+ | ✅ Supported |
| 3.10 – 3.15 | ✅ Tested in CI |
Development
git clone https://github.com/AhsanSheraz/pywho.git
cd pywho
uv venv && source .venv/bin/activate
uv pip install -e ".[dev]"
pytest -v
mypy src/pywho
License
Metadata
Release files for pywho 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pywho-0.4.0.tar.gz | 37.8 kB | With provenance | Details for pywho-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pywho-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for pywho-0.4.0-py3-none-any.whl |
Total release size: 79.1 kB
Release files / pywho-0.4.0.tar.gz
| Download URL | pywho-0.4.0.tar.gz |
|---|---|
| Size | 37.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
78ffd2d6f59eaeade3b02106dffda0d7dbc9246e96f16e239581b4be8c93accd
|
|
BLAKE2b-256 checksum How to use checksums |
54470150213e7b48429a13003916c20a12aaeb03f0a930518362561c016e8be3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logRelease files / pywho-0.4.0-py3-none-any.whl
| Download URL | pywho-0.4.0-py3-none-any.whl |
|---|---|
| Size | 41.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
372156ff053de7f5c1035286b4356daaf848bf7212faa5b9d0e26fe6fc23f2d1
|
|
BLAKE2b-256 checksum How to use checksums |
a920f77ab3faa5c3358a29879431651b3a310b3fd128ab2e7305b457fbb9f0d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logSecurity for pywho 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for pywho-0.4.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.