traceback

A traceback is the structured sequence of function calls that the Python interpreter prints whenever an exception (error) is raised. It details the path your code took right before crashing, pointing you to the exact file name, line number, and the type of error encountered.

Python Traceback
Traceback (most recent call last):
  File "example.py", line 5, in <module>
    result = divide(10, 0)
  File "example.py", line 2, in divide
    return a / b
ZeroDivisionError: division by zero

Reading tracebacks is essential for debugging Python code. It lets you pinpoint the origin of the error and see how different functions relate in the call chain, so you can fix issues more quickly.

Tutorial

Understanding the Python Traceback

In this step-by-step tutorial, you'll learn how to read and understand the information you can get from a Python traceback. You'll walk through several examples of tracebacks and see some of the most common tracebacks in Python.

basics python

For additional information on related topics, take a look at the following resources:


By Dan Bader • Updated Jan. 14, 2025