ShareYourGroupShareYourGroupError Explainer

How to read a Python traceback

A traceback looks scary and is actually a map. Read it from the bottom.

Start at the last line

A Python traceback lists the calls that led to the error, with the newest at the bottom. The last line says what went wrong: the type of error, then a colon, then a message. Here is a real one, produced by a small program that prints a name that was misspelt:

Traceback (most recent call last):
  File "main.py", line 2, in <module>
    print(totl)
          ^^^^
NameError: name 'totl' is not defined. Did you mean: 'total'?

The type is NameError (a name was not found). The message names totl. Python even suggests total. In many cases this last line is all you need.

Then look at the line just above

The line above the error type shows the code that failed, with carets (^^^^) under the part that Python is complaining about in recent versions. Above it, File "main.py", line 2 tells you where. Open that file at that line.

The chain of calls

When the error is inside a function that was called by another function, the traceback has several File ... entries. Read them from top to bottom as "who called whom": the first is where your program started, the last is where it broke. Often the real mistake is in the last entry that belongs to your code, not in the library code below it. Lines that point into the Python installation or site-packages are library internals; scroll up to the last line of your own file.

The common error types, in one line each

TypeUsually means
SyntaxErrorThe code is not valid Python (a missing colon, bracket or quote)
IndentationErrorThe spaces at the start of a line are wrong
NameErrorA name is not defined (typo, or used before it exists)
TypeErrorAn operation got the wrong kind of value (text plus number, wrong number of arguments)
ValueErrorThe kind is right but the value is not (int("abc"))
IndexError, KeyErrorA position or a key that does not exist
AttributeErrorThe object has no such method or field
ImportError, ModuleNotFoundErrorA module could not be imported
FileNotFoundErrorA file or folder is not where the program looked
ZeroDivisionErrorA division by zero

Every one of these has its own page on this site, with the code that makes the error, the exact output and the fix.

A method that works

  1. Read the last line. Say it out loud in plain words.
  2. Open the file and line named in the last File entry that belongs to your code.
  3. Print or inspect the values on that line just before it runs: print(type(x), x).
  4. Change one thing and run again.
  5. If you are stuck, copy the last line (not the whole traceback) into a search, together with the word Python.
Why does the traceback say "most recent call last"?

It shows the calls in order, so the one that failed is at the bottom, closest to the error message.

What does "During handling of the above exception, another exception occurred" mean?

An error happened inside an except block while handling another error. Read both: the first is the original problem.

This is an independent guide. It is not connected with Python, Microsoft, Google, GitHub or the Git project. Product names belong to their owners. Examples were run on 13 November 2026 in a practice folder or a blank workbook; your version may word a message slightly differently.