Skip to main content

One command to explain your Python environment and trace import resolution.

Project description

pywho

One command to explain your Python environment and trace import resolution.

Ever asked "Which Python am I running? Why is it using that venv? Why did import X load that file?" — pywho answers all of it instantly.

$ pywho

  pywho - Python Environment Inspector
  ==============================================

  Interpreter
    Executable: /Users/dev/.venv/bin/python3
    Version:    3.12.3 (CPython)
    Compiler:   Clang 15.0.0 (clang-1500.3.9.4)
    Architecture: 64-bit

  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/3.12.3/Frameworks/Python.framework/Versions/3.12
    Site-packages: /Users/dev/myproject/.venv/lib/python3.12/site-packages

  Package Manager
    Detected:    uv
    pip version: 24.0

  sys.path
    [0] (empty string = cwd)
    [1] /opt/homebrew/Cellar/python@3.12/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python312.zip
    [2] /opt/homebrew/Cellar/python@3.12/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12
    ...

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.9+.

Installation

pip install pywho

Or with uv:

uv pip install pywho

Or run without installing:

uvx pywho

Usage

Basic inspection

pywho

JSON output (for CI, scripts, sharing)

pywho --json
{
  "interpreter": {
    "executable": "/usr/bin/python3",
    "version": "3.11.6",
    "implementation": "CPython",
    ...
  },
  "venv": {
    "is_active": false,
    "type": "none",
    ...
  },
  ...
}

Include installed packages

pywho --packages

Skip pip version check (faster)

pywho --no-pip

Run as module

python -m pywho

Trace an import

pywho trace requests
  Import Resolution: requests
  ========================================

  Resolved to: /Users/dev/.venv/lib/python3.12/site-packages/requests/__init__.py
  Module type: third-party (package)
  Cached:      No

  Search order:
    [0] /Users/dev/myproject        -> not found
    [1] /usr/lib/python3.12         -> not found
    [2] ~/.venv/lib/.../site-packages -> FOUND

Trace with full search log

pywho trace json --verbose

Trace with JSON output

pywho trace requests --json

Detect import shadows

$ pywho trace requests

  WARNING: './requests.py' shadows installed package 'requests'

As a Python library

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()

Trace imports programmatically

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.is_cached)        # True
print(trace.shadows)          # [] (empty = no shadows)

# Check for shadows
if trace.shadows:
    for s in trace.shadows:
        print(f"WARNING: {s.description}")

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 orig-prefix.txt in lib directory
uv uv = in pyvenv.cfg
conda CONDA_DEFAULT_ENV env var
poetry POETRY_ACTIVE env var
pipenv PIPENV_ACTIVE env var

Package managers

Detects: pip, uv, conda, poetry, pipenv, pyenv

Paths

  • sys.prefix, sys.base_prefix, sys.exec_prefix
  • All site-packages directories
  • Full sys.path with index numbers

Packages

With --packages: lists all installed packages with versions and locations.

Use cases

  • Debugging: Paste pywho --json output into bug reports
  • Onboarding: New team member runs pywho to verify their setup
  • CI/CD: Add pywho --json to your pipeline for environment snapshots
  • Support: Ask users to run pywho instead of 5 separate commands

Platforms

Platform Status
Linux Supported
macOS Supported
Windows Supported
Python Status
3.9 Supported
3.10 Supported
3.11 Supported
3.12 Supported
3.13 Supported
3.14 Supported

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

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pywho-0.2.0.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pywho-0.2.0-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file pywho-0.2.0.tar.gz.

File metadata

  • Download URL: pywho-0.2.0.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pywho-0.2.0.tar.gz
Algorithm Hash digest
SHA256 5254c82f387e3d8ced2c1d941d9795346901c8f5f566a2d353c7d096fcafec7c
MD5 a91e4ebd85f5789251f1d246e6aa1cb2
BLAKE2b-256 0f73804e29af072480df61e471eedb42f4b302d196750fd95f52c59b55399aee

See more details on using hashes here.

File details

Details for the file pywho-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pywho-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pywho-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0881f6c4b2c875b0665b3f555e9b4a3f64ca29f2b3b872cbf4020bf91b9f04dc
MD5 29a77a26f47dc007016e26915d0f865c
BLAKE2b-256 314cfb07f757481fbdb3778cc6e8c6e64587ece1b6aa493c9770f335dd94d57c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page