1. Reference to Python Built-in Exceptions or Errors

Being a versatile and dynamically typed language, Python programming provides a robust error-handling mechanism through the use of built-in exceptions. These exceptions are events or errors that occur during the program execution, and due to a rich set of built-in exceptions, Python handles different scenarios efficiently. In this tutorial, we will provide you with a list of all the built-in exceptions or errors in Python programming. Moreover, we will also provide you with a code snippet that you may utilize to acquire the complete and up-to-date list of all the built-in exceptions in Python programming. Lastly, we will also share the heirarchy of the Python built-in exceptions or errors.

2. Search Ultimate Reference For Python Built-in Exceptions

The table below comprises all the built-in exceptions or errors in Python language and serves as an ultimate guide or reference to the developers. You can use the input field to search for any exception or error from the table. These built-in exptions of Python programming are listed alphabetically.

The Exception class is the base class of all the built-in exceptions or errors in Python language.

2.1. Alphabetical Reference

Exception Description)
ArithmeticError This exception is raised when an error occurs in numeric calculations.
AssertionError This exception is raised when an assert statement fails.
AttributeError When an attribute reference or assignment fails, this exception is raised.
BaseException The base class for all built-in exceptions, providing common functionality for Python error handling.
BaseExceptionGroup A group of exceptions that allows handling multiple exceptions within a single except clause.
BlockingIOError When an I/O operation is blocked on an object like a socket or pipe, this exception is raised.
BrokenPipeError When trying to write to a pipe that has been closed by the other end, this exception is raised.
BufferError This exception is raised when a buffer-related operation fails.
BytesWarning This exception is related to a warning about bytes and bytearray operations.
ChildProcessError When an error occurs in a child process, this exception is raised.
ConnectionAbortedError When the connection is aborted by the network, this exception is raised.
ConnectionError This is the base class for exceptions related to connections.
ConnectionRefusedError This exception is raised when a connection attempt is refused by the peer.
ConnectionResetError When a connection is reset by the peer, this exception is raised.
DeprecationWarning When there are features that are no longer needed and may be deprecated in the future, this exception is raised.
EOFError This exception is raised when the input() function hits an "end of file" condition (EOF).
EncodingWarning This exception is a warning about issues related to Unicode encoding.
EnvironmentError It is a base class for the exceptions that can occur outside the Python system.
Exception This is the base class for all built-in exceptions in Python language.
ExceptionGroup A group of exceptions, but not a built-in exception in Python.
FileExistsError While trying to create a file or directory that already exists, this exception is raised.
FileNotFoundError While requesting a file or directory but cannot find it, this exception is raised.
FloatingPointError This exception is raised when a floating point operation or calculation fails.
FutureWarning This exception is a warning that is raised about a feature of Python that will be deprecated in the future.
GeneratorExit When a generator is closed with the close() method, this exception is raised.
IOError This is the base class for the I/O errors.
ImportError This exception is raised when we import a module that does not exist.
ImportWarning When there is a deprecated feature related to imports, this exception raises a warning.
IndentationError The base class for syntax errors related to incorrect indentation.
IndexError This exception is raised when a sequence subscript is out of range.
InterruptedError When a system call is interrupted by an incoming signal, this exception is raised.
IsADirectoryError When a file operation is requested on a directory, this exception is raised.
KeyError This exception is raised when a key does not exist in a Python dictionary.
KeyboardInterrupt This exception is raised when the user presses interrupts the program execution usually pressing CTRL+C.
LookupError When a key or index is not found, this exception is raised.
MemoryError When an operation runs out of memory, this exception is raised.
ModuleNotFoundError While trying to find a module that does not exist, this exception is raised.
NameError While trying to find a variable that does not exist, this exception is raised.
NotADirectoryError This exception is raised when an operation is requested on something that is not a directory.
NotImplementedError This exception is raised when an abstract method that needs to be implemented in an inherited class is not actually implemented.
OSError The base class for operating system-related errors
OverflowError When the result of an arithmetic operation is too large, this exception is raised.
PendingDeprecationWarning When a module is using a deprecated feature, but is still allowed for now, this exception is raised.
PermissionError While trying to perform an operation without necessary permissions, this exception is raised.
ProcessLookupError While looking at a process and the operation fails, this exception is raised.
RecursionError This exception is raised when the maximum recursion depth is reached.
ReferenceError This exception is raised when a weak reference proxy is used to access an object that does not exist.
ResourceWarning When there is a warning related to resource usage, this exception is raised.
RuntimeError A generic runtime error that does not fall into any specific category.
RuntimeWarning For runtime warnings, this exception is raised.
StopAsyncIteration This exception is raised by an asynchronous iterator's __anext__ method to signal the end of the iteration.
StopIteration To tell the end of the iteration in a regular iterator, this exception is raised.
SyntaxError This exception is raised when a syntax error occurs during program execution.
SyntaxWarning When the syntax is deprecated and other language-specific issues occur, this exception is raised.
SystemError When there is an internal error detected by the interpreter, it raises this exception.
SystemExit This exception is raised by the sys.exit() function to tell the interpreter should exit.
TabError This exception is raised when indentation contains inconsistent use of tabs or spaces.
TimeoutError When an operation times out, this exception is raised.
TypeError When an operation is performed on an object of an inappropriate type, this exception is raised.
UnboundLocalError An exception of this type is raised when a local variable is referenced before it has been assigned a value.
UnicodeDecodeError This exception is raised when decoding a Unicode-related encoding fails.
UnicodeEncodeError This exception is raised when encoding a Unicode-related encoding fails.
UnicodeError The base class for all Unicode-related errors.
UnicodeTranslateError When a Unicode translation problem occurs, this exception is raised.
UnicodeWarning This exception is raised for Unicode-related warnings.
UserWarning For user-generated warnings, this exception is raised.
ValueError When a function receives an argument of the correct type but an invalid value, this exception is raised.
Warning The base class for warning categories exceptions.
WindowsError This exception is raised when a Windows-specific error occurs.
ZeroDivisionError This exception is raised when the second operand of a division or modulo operation is zero.

3. Dynamically Get All Python Built-in Exceptions

To programmatically retrieve a complete list of all the built-in Python exceptions or errors, we can utilize the following code.

Get All Built-in Exceptions

# Get all built-in exceptions or errors
import builtins

# Get all attributes of the builtins module
all_attributes = dir(builtins)

# Filter out only the attributes that are classes and are exceptions
exceptions = [
attr
for attr in all_attributes
	if isinstance(getattr(builtins, attr), type) and issubclass(getattr(builtins, attr), BaseException)
]

# Print the list of exception names
for exception in exceptions:
	print(exception)

4. Heirarchy of Python Built-in Exceptions

The heirarchy of the built-in Python exceptions or errors shows that how the exceptions are related to each other. Further the Python built-in exceptions heirarchy dipicts different categories in which these are divided. See the Python built-in exceptions heirarchy below:

Exceptions Heirarchy

BaseException
 ├── BaseExceptionGroup
 ├── GeneratorExit
 ├── KeyboardInterrupt
 ├── SystemExit
 └── Exception
      ├── ArithmeticError
      │    ├── FloatingPointError
      │    ├── OverflowError
      │    └── ZeroDivisionError
      ├── AssertionError
      ├── AttributeError
      ├── BufferError
      ├── EOFError
      ├── ExceptionGroup [BaseExceptionGroup]
      ├── ImportError
      │    └── ModuleNotFoundError
      ├── LookupError
      │    ├── IndexError
      │    └── KeyError
      ├── MemoryError
      ├── NameError
      │    └── UnboundLocalError
      ├── OSError
      │    ├── BlockingIOError
      │    ├── ChildProcessError
      │    ├── ConnectionError
      │    │    ├── BrokenPipeError
      │    │    ├── ConnectionAbortedError
      │    │    ├── ConnectionRefusedError
      │    │    └── ConnectionResetError
      │    ├── FileExistsError
      │    ├── FileNotFoundError
      │    ├── InterruptedError
      │    ├── IsADirectoryError
      │    ├── NotADirectoryError
      │    ├── PermissionError
      │    ├── ProcessLookupError
      │    └── TimeoutError
      ├── ReferenceError
      ├── RuntimeError
      │    ├── NotImplementedError
      │    └── RecursionError
      ├── StopAsyncIteration
      ├── StopIteration
      ├── SyntaxError
      │    └── IndentationError
      │         └── TabError
      ├── SystemError
      ├── TypeError
      ├── ValueError
      │    └── UnicodeError
      │         ├── UnicodeDecodeError
      │         ├── UnicodeEncodeError
      │         └── UnicodeTranslateError
      └── Warning
           ├── BytesWarning
           ├── DeprecationWarning
           ├── EncodingWarning
           ├── FutureWarning
           ├── ImportWarning
           ├── PendingDeprecationWarning
           ├── ResourceWarning
           ├── RuntimeWarning
           ├── SyntaxWarning
           ├── UnicodeWarning
           └── UserWarning

5. Reference Links

To compile this ultimate and up-to-date reference or guide of all the Python built-in exceptions or errors, we consulted and gathered data from the sources below.

  • We gathered a built-in exceptions list from W3schools.com and built this ultimate reference guide for all Python errors.
  • Also, we explored Python's official reference to finalize this list of all built-in exceptions or errors.
Give Us Your Feedback
OR
If You Need Any Help!
Contact Us