{"library":"stackprinter","title":"Debug-friendly stack traces, with variable values and semantic highlighting","type":"library","description":"Stackprinter is a Python library that provides enhanced, debug-friendly stack traces. It displays more code context, current variable values, and uses semantic highlighting to make tracebacks more readable. The library is actively maintained, with a current version of 0.2.12, and receives updates periodically to support newer Python versions and address issues.","language":"python","status":"active","last_verified":"Sun May 17","install":{"commands":["pip install stackprinter"],"cli":null},"imports":["import stackprinter; stackprinter.set_excepthook()","import stackprinter; stackprinter.show()","import stackprinter; message = stackprinter.format()","from stackprinter import TracePrinter"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":null,"github":"https://github.com/cknd/stackprinter","docs":null,"changelog":null,"pypi":"https://pypi.org/project/stackprinter/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"import stackprinter\nimport logging\nimport sys\n\n# Option 1: Replace the default excepthook for all uncaught exceptions\n# stackprinter.set_excepthook(style='darkbg')\n\n# Option 2: Use in a try-except block or integrate with logging\n\nclass VerboseExceptionFormatter(logging.Formatter):\n    def formatException(self, exc_info):\n        # exc_info is a tuple (type, value, traceback)\n        msg = stackprinter.format(exc_info, style='darkbg', source_lines=7, truncate_vals=200)\n        return msg\n\ndef configure_logger(logger_name=None):\n    formatter = VerboseExceptionFormatter('%(asctime)s %(levelname)s: %(message)s')\n    handler = logging.StreamHandler(sys.stderr)\n    handler.setFormatter(formatter)\n    logger = logging.getLogger(logger_name)\n    logger.addHandler(handler)\n    logger.setLevel(logging.ERROR)\n    return logger\n\nlogger = configure_logger('my_app')\n\ndef problematic_function(a, b):\n    result = a / b\n    return result\n\ndef main():\n    x = 10\n    y = 0\n    try:\n        problematic_function(x, y)\n    except ZeroDivisionError:\n        logger.exception('An error occurred during calculation:')\n    except TypeError as e:\n        # For manual formatting and printing\n        print('\\n--- Manual stackprinter output ---\\n')\n        stackprinter.show(e, style='darkbg')\n\nif __name__ == '__main__':\n    main()","lang":"python","description":"This quickstart demonstrates two ways to use stackprinter: integrating with Python's standard logging module for automatic verbose exception logging, and manually calling `stackprinter.show()` within an `except` block for immediate, enhanced traceback output. The `set_excepthook()` method (commented out) is also available to globally replace Python's default exception printout.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-17","installed_version":"0.2.13","pypi_latest":"0.2.13","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":1.5,"avg_import_s":0.04,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"stackprinter","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.03,"mem_mb":1.4,"disk_size":"18.0M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"stackprinter","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.5,"import_time_s":0.02,"mem_mb":1.4,"disk_size":"18M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"stackprinter","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.05,"mem_mb":1.7,"disk_size":"19.8M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"stackprinter","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.6,"import_time_s":0.05,"mem_mb":1.7,"disk_size":"20M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"stackprinter","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.05,"mem_mb":1.6,"disk_size":"11.7M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"stackprinter","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.5,"import_time_s":0.05,"mem_mb":1.6,"disk_size":"12M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"stackprinter","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.06,"mem_mb":2.4,"disk_size":"11.4M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"stackprinter","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.4,"import_time_s":0.06,"mem_mb":2.2,"disk_size":"12M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"stackprinter","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.02,"mem_mb":1.4,"disk_size":"17.4M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"stackprinter","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.7,"import_time_s":0.02,"mem_mb":1.4,"disk_size":"18M"}]}}