PythonMastery
Error reference

Python errors, explained

60 errors you are likely to meet, each with what the error message means, the code that causes it, and the fix. Every example runs in the browser: break it, read the traceback, fix it, and run it again.

Holding the exact message? Paste it and we'll find the page, or find its family below. Only know when it broke? Browse by when it happens.

Paste your error

Paste the whole traceback, or just its last line. We'll find the page that fixes it, or show you how to read it if we don't have one yet. It's read here in your browser, and your error never leaves this tab unless you choose to send it to us.

By error type

28 families

TypeError15

AttributeError6

ValueError4

ImportError3

IndentationError3

RuntimeError3

SyntaxError3

IndexError2

OSError2

'python' is not recognized as an internal or external command1

ConnectionRefusedError1

FileNotFoundError1

KeyError1

  • KeyError: 'X'

    A KeyError is raised when you try to access a key in a dictionary (or a dict-like object) that does not exist.

MemoryError1

ModuleNotFoundError1

NameError1

  • NameError: name 'X' is not defined

    Python tried to look up the name X and couldn't find it in any scope: not in the local scope, not in the global scope, and not in the built-ins.

PermissionError1

RecursionError1

SSLCertVerificationError1

TabError1

TimeoutError / requests.exceptions.ReadTimeout1

UnboundLocalError1

UnicodeDecodeError1

UnicodeEncodeError1

ZeroDivisionError1

error1

json.JSONDecodeError1

socket.gaierror1

By when it happens

same 60 errors, different way in

while it runs33

The program is running and meets a value it cannot work with. The most common kind by far.

nextStill stuck?

An error not listed here usually means the traceback is pointing somewhere other than where the mistake is. Errors & Exceptions covers how to read one properly, and Exceptions: Patterns Beyond the Basics covers raising your own.