traceback-with-variables
Adds variables to python traceback. Simple, lightweight, controllable. Debug reasons of exceptions by logging or pretty printing colorful variable contexts for each frame in a stacktrace, showing every value. Dump locals environments after errors to console, files, and loggers. Works with Jupyter and IPython.
What it is and what it does
traceback-with-variables is a lightweight debugging utility that intercepts Python exceptions and automatically prints the values of all local variables at each stack frame, without requiring you to manually add logging or exception-handling boilerplate. Instead of writing try-except blocks with formatted error messages listing every variable, you import the module once and get rich, colorized variable context for free whenever an exception occurs.
It works as a global hook (via activate_by_import), a decorator on individual functions, or a context manager around code blocks. You can also print the current stack without an exception, customize variable display length and filtering, and route output to loggers instead of stdout. The package is designed for both development debugging and small-scale production use, where the ability to see exactly what values caused a crash can save hours of reproduction and log-digging.
Use it for:
- Quickly diagnose why a function failed in development without adding temporary print statements or try-except blocks.
- Log exceptions to a file or logger with full variable context for post-mortem debugging in production.
- Inspect local state in Jupyter notebooks or IPython sessions after an error without re-running cells.
- Reduce exception-handling boilerplate in data processing pipelines where you want to see intermediate values on failure.
- Customize traceback output (e.g., skip certain files, limit string length) to keep logs readable while retaining key debug info.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Automatically captures and displays local variables in Python tracebacks, eliminating manual debug logging while keeping exception context readable.
Yes. Zero runtime dependencies, permissive license, active maintenance, and no known vulnerabilities make it a safe, low-friction addition. The core value—eliminating repetitive debug logging—is real and saves time in both development and production troubleshooting. Install it if you regularly spend time reconstructing variable state from exceptions.
Install
traceback-with-variables on PyPI
pip
pip install traceback-with-variablesuv
uv add traceback-with-variablespoetry
poetry add traceback-with-variablesInstalling traceback-with-variables
Before you install
Low friction—pure Python wheel with no runtime dependencies. Actively maintained with recent commits and steady adoption (761416 monthly downloads).
License in practice
MIT license (permissive) means you can use, modify, and distribute freely with minimal restrictions.
Quickstart
pip install traceback-with-variables==2.2.1
from traceback_with_variables import activate_by_import
# Your code now prints variables on any exception
def divide(a, b):
return a / b
divide(10, 0) # Traceback will show a, b values
Requires Python 3.7 or later.
Verify before relying
- Performance overhead when printing very large objects or deeply nested structures—description mentions speed but provides no benchmarks.
- Behavior with sensitive data (passwords, tokens) in logs—documentation warns about this but does not detail filtering or redaction mechanisms.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 294 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 761,416/month — #5,128 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: traceback_with_variables-2.2.1-py3-none-any.whl
Keywords: python, traceback, locals, logging, debugging, print, variables, python3, stacktrace, arguments, errors, error-handling, dump, exception-handling, exceptions, pretty, pretty-print, frame, simple, colors, jupyter, jupyter-notebook, ipython, customize
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
tracebackturbo3A drop-in replacement for Python's traceback…
permissive · top 15,000 on PyPI
traceriteFormats Python exceptions and tracebacks into…
permissive · top 5,000 on PyPI
environManages stack-based global variables that can…
copyleft · top 15,000 on PyPI
snoopsnoop adds decorator-based and context-manager…
permissive · top 15,000 on PyPI
tblibSerializes exceptions and tracebacks to pickle…
permissive · top 1,000 on PyPI
mozcrashExtracts and formats stack traces from minidump…
copyleft · top 15,000 on PyPI
crashtestCrashtest provides utilities to catch, inspect,…
permissive · top 1,000 on PyPI
stackprinterReplaces Python's default exception traceback…
permissive · top 15,000 on PyPI
better-exceptionsFormats Python exceptions with syntax…
unclear · top 15,000 on PyPI
wasabiWasabi provides lightweight console printing…
permissive · top 5,000 on PyPI