Stockertim Dictionary · Technology
Traceback
Also called Python traceback, stack trace, error traceback
In short
The error report Python prints when a program fails, listing the chain of calls that led to the failure and ending with the error type and a message.
- Beginner
- Concept
- Checked
In detail
When Python meets an error it cannot handle, it stops and prints a traceback. The report starts with the words Traceback (most recent call last) and then lists, from the outermost call to the innermost, each file, line number and function that was running, with the line of code itself. The last line names the type of error and gives a short description.
The bottom line is where to start reading. NameError means a name was used before being defined, often because of a typo. TypeError means an operation was given the wrong kind of value, such as adding text to a number. KeyError means a dictionary lookup used a key that is not there, IndexError means a position beyond the end of a list, and FileNotFoundError means a path is wrong.
The frames above the last line show how the program got there. The deepest frame that belongs to the user's own code, rather than to a library, is usually the line to fix, even when the error was raised inside the library. In a code notebook the traceback appears under the cell that failed and highlights the offending line.
A traceback is information, not a verdict, and it is the most useful thing to share when asking for help, whether from a colleague or an AI assistant. Pasting it whole, with the few lines of code it points to, gives the reader the error type, the location and the path. It is worth checking first that it contains no passwords, keys or personal data before sharing.
Worked example
An analyst at a logistics firm in Mombasa runs a script and gets a traceback ending: TypeError: unsupported operand type(s) for +: 'int' and 'str'.
- The last frame from the analyst's own script points at
total = total + row['weight']. - Printing
row['weight']shows'25', a value in quotes, so the weights were read from the file as text. - Converting with
float(row['weight'])fixes the line, and the script then reports 1,200 parcels.
Reading the bottom line first and then the analyst's own frame located the fault in under a minute.
In practice
Developers and analysts read tracebacks dozens of times a day. Teams often paste them into a ticket or a chat with the failing code so that others can reproduce the problem, and logs of scheduled jobs keep tracebacks so that overnight failures can be diagnosed in the morning.
Watch out
- The real cause can sit earlier than the reported line, for example where a value was first read with the wrong type.
- No traceback does not mean no error; code can finish normally and still produce wrong figures.
Learn it properly
Official sources
- Quality assurance of code for analysis and research · Government Analysis Function
- Guidelines for secure AI system development · National Cyber Security Centre
Facts last checked on 9 November 2026.
Education, not advice: the Stockertim Dictionary explains what terms mean. It never recommends buying or selling anything.