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.
Raised when a file or directory is requested but doesnβt exist.
IOError
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.
PermissionError
Raised when trying to run an operation without the adequate access rights.
EOFError
Raised when there is no input from either the raw_input() or input() function and the end of file is reached.
KeyboardInterrupt
Raised when the user interrupts program execution, usually by pressing Ctrl+c.
Base class for all exceptions. This catches most exception messages.
StopIteration
Raised when the next() method of an iterator does not point to any object.
AssertionError
Raised in case of failure of the Assert statement.
SystemExit
Raised when Python interpreter is quit by using the sys.exit() function. If not handled in the code, it causes the interpreter to exit.
OSError
Raises for operating system related errors.
EnvironmentError
Base class for all exceptions that occur outside the Python environment.
AttributeError
Raised in case of failure of an attribute reference or assignment.
NotImplementedError
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.