skillfed

stackprinter

Debug-friendly stack traces, with variable values and semantic highlighting

stackprinter v0.2.13 444.7K downloads/30d#6,621 on PyPI1,299
Permissive license Active released

What it is and what it does

stackprinter is a Python debugging utility that intercepts exceptions and prints them with significantly more context than the standard traceback. Instead of showing only the line that failed, it displays surrounding source code, the values of all variables visible at each frame, and how each function was called—answering the questions you'd normally ask an interactive debugger without requiring one.

It works in three modes: as a global exception hook (replacing the default crash message), called selectively in except blocks, or integrated with Python's logging module. Output is plain text by default (suitable for log files) but supports color modes for terminal use. Configuration options let you control verbosity, hide sensitive variables, truncate large values, and suppress output from specific code paths.

Use it for:

  • Debugging production errors where only log files are available, not an interactive debugger.
  • Logging exceptions with full context in long-running services or batch jobs.
  • Replacing the default REPL crash message with more informative output via sitecustomize.py.
  • Inspecting the current call stack and variable state at any point in code, not just on exception.
  • Examining another thread's stack during concurrent debugging.
  • Integrating enhanced tracebacks into a custom logging formatter for structured error reporting.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Replaces Python's default exception traceback with an enhanced version that shows surrounding code context and the values of nearby variables at each stack frame.

Yes. Zero dependencies, permissive license, active maintenance, and no known vulnerabilities. Install it if you spend time debugging Python code or need better error context in production logs—it's a low-risk, high-value addition to any Python project.

Install

stackprinter on PyPI

pip

pip install stackprinter

uv

uv add stackprinter

poetry

poetry add stackprinter

Installing stackprinter

Before you install

Low friction—pure Python wheel with no runtime dependencies. Actively maintained with recent commits and a solid user base.

License in practice

MIT license permits unrestricted use, modification, and distribution in both open and closed projects.

Quickstart

pip install stackprinter

import stackprinter
stackprinter.set_excepthook(style='darkbg2')

# or in an except block:
try:
    risky_call()
except:
    stackprinter.show()

Package facts

License not declared (permissive)
Python support supports the current Python release (>=3.4)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 119 days since the last release
Last repo commit
First released
Downloads 444,664/month — #6,621 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: stackprinter-0.2.13-py3-none-any.whl

License :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3

Tags

better python tracebacksexception debugging with variablesenhanced stack tracespython crash output formattingdebug traceback with contextvariable inspection in exceptionsreadable error messages
debuggingerror-handlinglogging

More Quality Assurance packages