better-exceptions
Pretty and helpful exceptions, automatically
What it is and what it does
better-exceptions hooks into Python's exception system to display tracebacks with syntax highlighting and local variable values inline, making it easier to understand what went wrong at a glance. It works by setting an environment variable and is designed to be transparent—once activated, all exceptions in your Python process are automatically formatted without code changes. The package depends only on colorama for terminal color support.
You can use it in regular scripts, the Python REPL (via `python -m better_exceptions`), unittest test runners (with a monkey patch), or Django applications (via middleware). Advanced usage allows disabling value truncation. The package is intended for development and debugging; the documentation explicitly warns against leaving the environment variable set in production to avoid leaking sensitive data in logs.
Use it for:
- Interactive debugging in the Python REPL to see local variables and syntax-highlighted code context.
- Development workflows where you want richer exception output without modifying application code.
- Django projects where middleware integration provides formatted exceptions across the entire request lifecycle.
- Unit test debugging to see better-formatted assertion failures and error context.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Formats Python exceptions with syntax highlighting and local variable inspection to make debugging easier, activated via an environment variable.
Yes, if you do development work in Python and want better exception visibility without code changes. The low install friction, active maintenance, and zero known vulnerabilities make it a safe addition to a development environment. Not necessary for production unless you explicitly want formatted exception logging, in which case be careful to disable the environment variable in production.
Install
better-exceptions on PyPI
pip
pip install better-exceptionsuv
uv add better-exceptionspoetry
poetry add better-exceptionsInstalling better-exceptions
Before you install
Low install friction with a single lightweight dependency (colorama). Actively maintained as of July 2026, though the latest release was in January 2021.
License in practice
License treatment is unclear in the metadata; the description references MIT licensing, but this is not formally declared in the package metadata.
Quickstart
pip install better-exceptions
export BETTER_EXCEPTIONS=1
python -m better_exceptions
Requires the BETTER_EXCEPTIONS environment variable to be set; without it, exceptions display normally.
Verify before relying
- Whether the package works with current Python versions (requires_python is unspecified in metadata).
- Whether the MIT license claim in the description is the authoritative license for this package.
Package facts
| License | not declared (unclear) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — colorama |
| Maintenance | actively maintained — 2,023 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 589,528/month — #5,861 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: better_exceptions-0.3.3-py3-none-any.whl
Keywords: pretty, better, exceptions, exception, error, local, debug, debugging, locals
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
traceriteFormats Python exceptions and tracebacks into…
permissive · top 5,000 on PyPI
lib-cli-exit-toolsProvides portable signal handling,…
permissive · top 15,000 on PyPI
resultProvides a Rust-inspired Result type for Python…
permissive · top 5,000 on PyPI
crashtestCrashtest provides utilities to catch, inspect,…
permissive · top 1,000 on PyPI
prettyprinterSyntax-highlighted, declarative pretty printer…
permissive · top 5,000 on PyPI
traceback-with-variablesAutomatically captures and displays local…
permissive · top 15,000 on PyPI
colour-runnerAdds colored output to Python's unittest test…
permissive · top 15,000 on PyPI
pyupgradeAutomatically rewrites Python source code to…
permissive · top 5,000 on PyPI
zope.exceptionsProvides general-purpose exception classes and…
unclear · top 15,000 on PyPI
djhtmlDjHTML indents Django and Jinja template files…
copyleft · top 15,000 on PyPI