Most of the standard exceptions built into Python are listed below. They are organized into related groups based on the types of issues they deal with.
Base class for all built-in exceptions except StopIteration and SystemExit.
Raised when an import statement fails.
Raised when there is an error in Python syntax.
Raised when indentation is not specified properly.
Raised when an identifier is not found in the local or global namespace.
Raised when trying to access a local variable in a function or method but no value has been assigned to it.
Raised when an operation or function is attempted that is invalid for the specified data type.
Base class for all lookup errors.
Raised when an index is not found in a sequence.
Raised when the specified key is not found in the dictionary.
Raised when the built-in function for a data type has the valid type of arguments, but the arguments have invalid values specified.
Raised when a generated error does not fall into any category.
Raised when a operation runs out of memory.
Raised when the maximum recursion depth has been exceeded.
Raised when the interpreter finds an internal problem, but when this error is encountered the Python interpreter does not exit.
Base class for all errors that occur for numeric calculation. You know a math error occurred, but you don’t know the specific error.
Raised when a calculation exceeds maximum limit for a numeric type.
Raised when a floating point calculation fails.
Raised when division or modulo by zero takes place for all numeric types.
Raised when a file or directory is requested but doesn’t exist.
Raised when an input/ output operation fails, such as the print statement or the open() function when trying to open a file that does not exist. Also raised for operating system-related errors.
Raised when trying to run an operation without the adequate access rights.
Raised when there is no input from either the raw_input() or input() function and the end of file is reached.
Raised when the user interrupts program execution, usually by pressing Ctrl+c.
Base class for all exceptions. This catches most exception messages.
Raised when the next() method of an iterator does not point to any object.
Raised in case of failure of the Assert statement.
Raised when Python interpreter is quit by using the sys.exit() function. If not handled in the code, it causes the interpreter to exit.
Raises for operating system related errors.
Base class for all exceptions that occur outside the Python environment.
Raised in case of failure of an attribute reference or assignment.
Raised when an abstract method that needs to be implemented in an inherited class is not actually implemented.
All exceptions are objects. The classes that define the objects are organized in a hierarchy, which is shown below. This is important because the parent class of a set of related exceptions will catch all exception messages for itself and its child exceptions. For example, an ArithmeticError exception will catch itself and all FloatingPointError, OverflowError, and ZeroDivisionError exceptions.