PrettyErrors

1.2.25 · active · verified Thu Apr 16

PrettyErrors is a Python library designed to make Python exception output more legible and user-friendly. It provides color coding, simplifies tracebacks, and categorizes errors, making it easier for developers to understand what went wrong and how to fix it. The current version is 1.2.25. Its release cadence is irregular, with updates typically driven by new features or bug fixes rather than a strict schedule.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import and optionally configure `pretty_errors` to format exception output. It then triggers a `ZeroDivisionError` to show the prettified traceback. For universal activation across all Python runs (including `SyntaxError`), run `python -m pretty_errors` in your terminal once after installation.

import pretty_errors

# Optional: Configure pretty_errors for customized output
pretty_errors.configure(
    separator_character = '#',
    filename_display = pretty_errors.FILENAME_EXTENDED,
    line_number_first = True,
    display_link = True,
    lines_before = 3,
    lines_after = 2,
    line_color = pretty_errors.RED + '> ' + pretty_errors.default_config.line_color,
    code_color = ' ' + pretty_errors.default_config.line_color,
    truncate_code = True,
    display_locals = True
)

def calculate_division(numerator, denominator):
    return numerator / denominator

# This will intentionally cause a ZeroDivisionError
print(calculate_division(10, 0))

view raw JSON →