Error Types

These are the most common built in exceptions in Python.

ERROREXPLANATION
ValueErrorRaised when a function receives an argument of the right type but an inappropriate value.
TypeErrorRaised when an operation or function is applied to an object of inappropriate type.
FileNotFoundErrorRaised when trying to open a file that does not exist.
IndexErrorRaised when trying to access an element from a list or tuple with an invalid index.
KeyErrorRaised when trying to access a dictionary with a key that does not exist.
AttributeErrorRaised when an attribute reference or assignment fails.
ImportErrorRaised when an import statement fails to find the module definition or when a from ... import fails.
ModuleNotFoundErrorRaised when a module could not be found.
ZeroDivisionErrorRaised when attempting to divide by zero.
NameErrorRaised when a local or global name is not found.
UnboundLocalErrorRaised when trying to access a local variable before it has been assigned.
SyntaxErrorRaised when the parser encounters a syntax error.
IndentationErrorRaised when there is an incorrect indentation.
TabErrorRaised when mixing tabs and spaces in indentation.
IOErrorRaised when an I/O operation (such as a print statement or the open() function) fails.
OSErrorRaised when a system-related operation causes an error.
StopIterationRaised to signal the end of an iterator.
RuntimeErrorRaised when an error is detected that doesn't fall in any of the other categories.
RecursionErrorRaised when the maximum recursion depth is exceeded.
NotImplementedErrorRaised by abstract methods that need to be implemented by subclasses.
AssertionErrorRaised when an assert statement fails.
FloatingPointErrorRaised when a floating point operation fails.
OverflowErrorRaised when the result of an arithmetic operation is too large to be expressed.
MemoryErrorRaised when an operation runs out of memory.
EOFErrorRaised when the input() function hits an end-of-file condition.
KeyboardInterruptRaised when the user hits the interrupt key (usually Ctrl+C or Delete).
ConnectionErrorBase class for network-related errors.
TimeoutErrorRaised when a system function times out.
BrokenPipeErrorRaised when a pipe is broken during a write operation.
IsADirectoryErrorRaised when a file operation (such as open()) is attempted on a directory.
PermissionErrorRaised when trying to perform an operation without the necessary permissions.
ChildProcessErrorRaised when a child process operation fails.
BlockingIOErrorRaised when an operation would block on an object (like a socket) set for non-blocking mode.
SystemExitRaised by the sys.exit() function.
GeneratorExitRaised when a generator’s close() method is called.