Tracerite: Human-Readable Exception Tracebacks

2.3.1 · active · verified Sat Apr 11

Tracerite is a Python library that transforms standard Python exception tracebacks into highly readable HTML or formatted TTY output. It is actively maintained, with frequent releases (current version 2.3.1), providing features like chronological ordering of chained exceptions, minimalistic output by pruning irrelevant details, and variable inspection across various environments, including terminals, Jupyter notebooks, and web frameworks like FastAPI and Sanic.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to enable Tracerite for all uncaught exceptions in a Python script. Simply import `tracerite` and call `tracerite.load()`. Any subsequent unhandled exception will be processed and displayed in a human-readable format, either in the terminal or as HTML in compatible environments.

import tracerite

tracerite.load()

def divide_by_zero(a, b):
    result = a / b
    return result

def main():
    x = 10
    y = 0
    print(f"Attempting to divide {x} by {y}")
    divide_by_zero(x, y)

if __name__ == '__main__':
    try:
        main()
    except Exception:
        # Tracerite will automatically handle uncaught exceptions
        # You won't typically wrap main() in a try-except if using tracerite.load()
        # This is just to show the immediate effect if not letting it propagate.
        pass

# When run, this will output a formatted traceback to stderr (TTY) or HTML (Jupyter/Web)

view raw JSON →