PySnooper
A poor man's debugger for Python.
What it is and what it does
PySnooper is a lightweight debugging decorator that replaces ad-hoc print statements with structured execution logging. When you decorate a function with @pysnooper.snoop(), it automatically logs every line executed, the order in which they run, and the exact moment each local variable changes. The output goes to stderr by default but can be redirected to a file or custom stream.
It's designed for situations where setting up a full debugger feels like overkill—you just want to see what your code is actually doing. You can trace entire functions or wrap specific code blocks in a context manager. It supports watching arbitrary expressions beyond just local variables and can follow execution into called functions via a depth parameter.
Use it for:
- Trace execution flow through a complex function to understand control flow without a debugger.
- Log variable state changes during development to catch unexpected mutations or initialization bugs.
- Debug legacy or enterprise code where attaching a debugger is impractical or slow.
- Inspect function behavior in production-like environments by redirecting output to a log file.
- Watch specific expressions like object attributes or dictionary keys during execution.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
PySnooper is a decorator-based debugging tool that logs function execution line-by-line, showing which lines run and how local variables change, without requiring debugger setup.
Yes. PySnooper is a zero-friction, actively maintained tool with no dependencies and a permissive license. It solves a real debugging workflow gap—faster than print debugging, simpler than a full debugger setup. Install it if you debug Python code interactively.
Install
pysnooper on PyPI
pip
pip install pysnooperuv
uv add pysnooperpoetry
poetry add pysnooperInstalling PySnooper
Before you install
Low friction: pure Python wheel with no runtime dependencies. Actively maintained with recent commits.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open and closed projects.
Quickstart
pip install pysnooper
import pysnooper
@pysnooper.snoop()
def my_function():
x = 1
y = x + 2
return y
my_function()
Verify before relying
- Actual repository star count and download volume to assess community adoption and reliability.
Package facts
| License | not declared (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 440 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 525,918/month — #6,182 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: PySnooper-1.2.3-py2.py3-none-any.whl
Tags
More Debuggers packages
Extracts and displays stack frame and traceback…
permissive · top 1,000 on PyPI
debugpydebugpy is a Debug Adapter Protocol…
permissive · top 1,000 on PyPI
pylintPylint is a static code analyzer that checks…
copyleft · top 1,000 on PyPI
yamllintyamllint checks YAML files for syntax errors,…
copyleft · top 1,000 on PyPI
ipdbipdb is an IPython-enabled debugger that…
permissive · top 5,000 on PyPI
memrayMemray is a memory profiler for Python that…
permissive · top 5,000 on PyPI
snoopsnoop adds decorator-based and context-manager…
permissive · top 15,000 on PyPI
AutologgingAutologging provides decorators to…
permissive · top 15,000 on PyPI
devtoolsProvides a `debug()` function that prints…
permissive · top 5,000 on PyPI
pydevd-pycharmPyCharm's debugger backend for remote debugging…
permissive · top 15,000 on PyPI
pydevdpydevd is a Python debugger backend that…
copyleft · top 5,000 on PyPI
memory-profilerProfiles memory consumption line-by-line in…
permissive · top 5,000 on PyPI
pudbPuDB is a full-screen console-based visual…
permissive · top 5,000 on PyPI
line-profilerline_profiler measures execution time on a…
permissive · top 5,000 on PyPI
aiodebugaiodebug provides monitoring and testing…
permissive · top 15,000 on PyPI
icecreamIceCream provides a drop-in replacement for…
permissive · top 5,000 on PyPI