🌐
Tutorial Teacher
tutorialsteacher.com › python › error-types-in-python
Error Types in Python
Learn about built-in error types in Python such as IndexError, NameError, KeyError, ImportError, etc.
🌐
Python
docs.python.org › 3 › builtins › exceptions.html
Built-in Exceptions — Python 3.14.7 documentation
Passing arguments of the wrong type (e.g. passing a list when an int is expected) should result in a TypeError, but passing arguments with the wrong value (e.g. a number outside expected boundaries) should result in a ValueError. ... Raised when a reference is made to a local variable in a function or method, but no value has been bound to that variable. This is a subclass of NameError. ... Raised when a Unicode-related encoding or decoding error ...
Discussions

What are the different types of errors in python? - Stack Overflow
Is zerodivisionerror is also a type of runtime error ... In general you can always subclass Exception though, so it's impossible to list all possible exceptions. ... In addition to this, it can be any subclass of BaseException. In Python <=2.5 you could raise a string too... More on stackoverflow.com
🌐 stackoverflow.com
How Can I Find a List of All Exceptions That a Given Library Function Throws in Python? - Stack Overflow
You can either try to grok the ... the Python API to do this. To first find which exception types a module defines, just write a simple script to go through each object in the module dictionary module.__dict__ and see if it ends in the word "Error" or if it is a subclass of Exception: Copydef listexns(mod): """Saved ... More on stackoverflow.com
🌐 stackoverflow.com
View Python traceback as quickfix
This should actually be pretty easy assuming there is already a compiler plugin capable of parsing the stacktrace you're receiving. Just set the compiler like you normally would, then override makeprg to cat/type the file to stdout. Let's take the example of a Python traceback. The first thing you'll want to do is install a compiler plugin capable of parsing tracebacks, like this one . Then open the file in a buffer, run :compiler python, then set makeprg=cat\ % (or :set makeprg=type\ % in Windows). Then just run :make. And you're good to go. More on reddit.com
🌐 r/vim
3
6
March 21, 2017
Deep learning: Memory error with arrays and lists in python

First of all, 25396 images seems like a very low number, especially if you're building your own CNN. The n/w will most likely always overfit to your data and pick up sampling errors. Karpathy himself has quoted - "Don't try to be a hero". Most of the time, you'll be battling the variance, which will just result in you dumbing down your own network. Have you tried transfer learning?

Regarding the memory problem - It's pretty obvious. You're loading two tensors of shapes (25369, 204, 204, 3) and (25369, 39) directly into memory, which seems to be too much. If you're using Keras, use the ImageDataGenerator utility and it's flow_from_directory method. You can stream images from folders with a specific batch size - very handy while handling a large number of images.

More on reddit.com
🌐 r/deeplearning
4
5
May 29, 2018
People also ask

How many types of errors are there in Python?
Three: syntax errors, runtime errors, and logical errors. Every named exception, such as TypeError or KeyError, is a specific case that belongs to one of these three categories rather than a fourth type of its own.
🌐
last9.io
last9.io › blog › types-of-errors-in-python
Types of Errors in Python: Syntax, Runtime, and Logical Explained ...
What are the three types of errors in Python?
A syntax error means the code breaks Python's grammar rules, so the interpreter refuses to run the file at all. A runtime error occurs while the program is running and stops it partway, such as dividing by zero or opening a file that does not exist. A logical error runs to completion without complaint but produces the wrong result, because the instructions themselves are wrong.
🌐
last9.io
last9.io › blog › types-of-errors-in-python
Types of Errors in Python: Syntax, Runtime, and Logical Explained ...
What are common Python errors?
The most common Python errors consist of SyntaxError, NameError, TypeError, ValueError, IndexError, KeyError, and AttributeError.
🌐
middleware.io
middleware.io › blog › python-error-types
Python Error Types: Common Errors and How to Handle Them
🌐
Last9
last9.io › blog › types-of-errors-in-python
Types of Errors in Python: Syntax, Runtime, and Logical Explained | Last9
January 3, 2025 - Python errors fall into three types: syntax, runtime, and logical. What each one means, the exceptions that belong to it, and how to fix them.
🌐
Rollbar
rollbar.com › home › what are the different types of python errors? – and how to handle them
What are the Different Types of Python Errors? – and How to Handle Them
Learn how to fix common Python errors: SyntaxError, TypeError, NameError, IndexError, and more. Each error type explained with code examples and solutions.
Published: July 14, 2025
🌐
Honeybadger
honeybadger.io › blog › errors-in-python
Errors in Python: Types, Causes, and Examples - Honeybadger Developer Blog
April 27, 2026 - Runtime errors occur in a Python program after it passes the syntax check and starts executing, when something goes wrong. Examples of runtime errors in Python include ZeroDivisionError, NameError, TypeError, and ValueError.
🌐
Berkeley
pythonnumericalmethods.studentorg.berkeley.edu › notebooks › chapter10.01-Error-Types.html
Error Types — Python Numerical Methods
There are three basic types of errors that programmers need to be concerned about: Syntax errors, runtime errors, and Logical errors. Syntaxis the set of rules that govern a language. In written and spoken language, rules can be bent or even broken to accommodate the speaker or writer.
🌐
Middleware
middleware.io › blog › python-error-types
Python Error Types: Common Errors and How to Handle Them
An AttributeError comes up when you try to access these attributes that either have a spelling mistake or do not exist for the object type. ... Python doesn’t have a method call push for strings. So, the above code will return AttributeError. ... The attribute name is color, but color was accessed, so it returned an error.
Find elsewhere
🌐
Python documentation
docs.python.org › 3 › tutorial › errors.html
8. Errors and Exceptions — Python 3.14.7 documentation
Most exceptions are not handled by programs, however, and result in error messages as shown here: >>> 10 * (1/0) Traceback (most recent call last): File "<stdin>", line 1, in <module> 10 * (1/0) ~^~ ZeroDivisionError: division by zero >>> 4 + spam*3 Traceback (most recent call last): File "<stdin>", line 1, in <module> 4 + spam*3 ^^^^ NameError: name 'spam' is not defined >>> '2' + 2 Traceback (most recent call last): File "<stdin>", line 1, in <module> '2' + 2 ~~~~^~~ TypeError: can only concatenate str (not "int") to str
🌐
Scaler
scaler.com › home › topics › what are the types of errors in python?
What are the Types of Errors in Python? | Scaler Topics
July 21, 2022 - ZeroDivisionError is raised by ... Indentation error is another type of error in python that can be summed up inside the syntax error....
🌐
Cornell Computer Science
cs.cornell.edu › courses › cs1110 › 2024fa › lectures › lecture24 › handout-24.pdf pdf
11/17/24 1 Error Types in Python def foo(): assert 1 == 2, 'My error' …
Python Error Type Hierarchy · BaseException · Exception · SystemExit · AssertionError · ArithmeticError · AttributeError · ValueError · TypeError · IOError · … · ZeroDivisionError · OverflowError · … · Argument has · wrong type · (e.g. float([1])) Argument has ·
Top answer
1 of 1
3

These errors can, and should, be defined by modules and projects as they are developed - so, there is no limited and "closed" set of errors like you are asking for.

Python introspection capabilities allow one to see, through the interactive console, which errors are defined as derived directly from "Exception" - but there could be more:

>>> [err.__name__ for err in  Exception.__subclasses__()]
['TypeError', 'StopIteration', 'ImportError', 'OSError', 'EOFError', 'RuntimeError', 'NameError', 'AttributeError', 'SyntaxError', 'LookupError', 'ValueError', 'AssertionError', 'ArithmeticError', 'SystemError', 'ReferenceError', 'BufferError', 'MemoryError', 'Warning', 'error', 'Error']

Note that exception itself is derived from BaseException, which subclasses are not limited to "error" exceptions, but to Exceptions used in flow control as well:

>>> [err.__name__ for err in  BaseException.__subclasses__()]
['Exception', 'GeneratorExit', 'SystemExit', 'KeyboardInterrupt']

Bottom line: knowing the total number of errors is impossible and irrelevant for learning the language. Each function/library you are dealing with can define new ones, and you should check the documentation to know which exceptions they can throw.

(On a side note, the __sublass__ method I used above does return a list of the classes that are direct descendants of that class. I them pick the __name__ attribute of each class to display)

The document posted by @GP89 in the comments will also show the errors which are not direct descendants of exception: https://docs.python.org/2/library/exceptions.html#exception-hierarchy

🌐
Geek University
geek-university.com › home › types of errors
Types of errors | Python#
February 1, 2022 - This article describes the two types of errors in Python - the compile time and runtime errors.
🌐
DEV Community
dev.to › namimai › python-error-types-explained-troubleshooting-for-beginners-4o76
Python Error Types Explained: Troubleshooting for Beginners - DEV Community
February 23, 2025 - Assertions are commonly used in testing and debugging to ensure certain conditions are met during runtime. If an assertion fails, Python immediately raises an error with a custom message, which can be helpful for tracking down logical issues. Index errors are raised when you try to access an element at an index past the end of the list.
🌐
Medium
medium.com › @techwithpraisejames › types-of-errors-in-python-and-how-to-handle-them-fe8616257b52
Common Types of Errors in Python and How to Handle Them | by Praise James | Medium
August 7, 2025 - You will typically get this error when the index you provide is out of the valid range for that particular sequence as shown below: numbers = [1, 2, 3, 4, 5] print(numbers[5]) #This will raise an IndexError since the valid indices for 'numbers' are 0, 1, 2, 3, and 4. ... This code attempts to access the element at index 5 in the list ‘numbers’, which is out of range. That’s why the code returned an IndexError. Remember that indexing in Python starts from 0.
🌐
Programiz
programiz.com › python-programming › exceptions
Python Exceptions (With Examples)
Online Python Online JavaScript Online SQL Online Java Online HTML Online C Online C++ Online C# Online PHP Online Swift Online Kotlin Online TypeScript Online Go Online Rust Online Scala Online Dart Online R Online Ruby ... An exception is an unexpected event that occurs during program execution. For example, ... The above code causes an exception as it is not possible to divide a number by 0. Let's learn about Python Exceptions in detail. Errors that occur at runtime (after passing the syntax test) are called exceptions or logical errors.
🌐
Qodo
qodo.ai › blog › learn › common python error types and how to resolve them
Common Python error types and how to resolve them
March 20, 2025 - IndexError is one of Python’s runtime errors that manifests when code attempts to access a sequence index that exceeds its bounds. You’ll come across this error type mostly when dealing with list operations, string manipulations, and array processing when the requested index falls outside the valid range viz.
🌐
YouTube
youtube.com › jean-christophe chouinard
3 Main Python Error & Exception Types #python #pythonprogramming - YouTube
-----Install Python:- MacOS: https://www.jcchouinard.com/install-python-on-macos/- Windows: https://www.jcchouinard.com/install-python-on-windows/- Anaconda...
Published: March 31, 2025
Views: 6
Top answer
1 of 4
12

To amplify Messa, catch what you expect are failure modes that you know how to recover from. Ian Bicking wrote an article that addresses some of the overarching principles as does Eli Bendersky's note.

The problem with the sample code is that it is not handling errors, just prettifying them and discarding them. Your code does not "know" what to do with a NameError and there isn't much it should do other than pass it up, look at Bicking's re-raise if you feel you must add detail.

IOError and OSError are reasonably "expectable" for a shutil.move but not necessarily handleable. And the caller of your function wanted it to move a file and may itself break if that "contract" that Eli writes of is broken.

Catch what you can fix, adorn and re-raise what you expect but can't fix, and let the caller deal with what you didn't expect, even if the code that "deals" is seven levels up the stack in main.

2 of 4
5

Python doesn't have a mechanism right now for declaring which exceptions are thrown, unlike (for example) Java. (In Java you have to define exactly which exceptions are thrown by what, and if one of your utility methods needs to throw another exception then you need to add it to all of the methods which call it which gets boring quickly!)

So if you want to discover exactly which exceptions are thrown by any given bit of python then you need to examine the documentation and the source.

However python has a really good exception hierarchy.

If you study the exception hierarchy below you'll see that the error superclass you want to catch is called StandardError - this should catch all the errors that might be generated in normal operations. Turning the error into into a string will give a reasonable idea to the user as to what went wrong, so I'd suggest your code above should look like

from shutil import move
try:
    move('somefile.txt', '/tmp/somefile.txt')
except StandardError, e:
    print 'Move failed: %s' % e

Exception hierarchy

BaseException
|---Exception
|---|---StandardError
|---|---|---ArithmeticError
|---|---|---|---FloatingPointError
|---|---|---|---OverflowError
|---|---|---|---ZeroDivisionError
|---|---|---AssertionError
|---|---|---AttributeError
|---|---|---BufferError
|---|---|---EOFError
|---|---|---EnvironmentError
|---|---|---|---IOError
|---|---|---|---OSError
|---|---|---ImportError
|---|---|---LookupError
|---|---|---|---IndexError
|---|---|---|---KeyError
|---|---|---MemoryError
|---|---|---NameError
|---|---|---|---UnboundLocalError
|---|---|---ReferenceError
|---|---|---RuntimeError
|---|---|---|---NotImplementedError
|---|---|---SyntaxError
|---|---|---|---IndentationError
|---|---|---|---|---TabError
|---|---|---SystemError
|---|---|---TypeError
|---|---|---ValueError
|---|---|---|---UnicodeError
|---|---|---|---|---UnicodeDecodeError
|---|---|---|---|---UnicodeEncodeError
|---|---|---|---|---UnicodeTranslateError
|---|---StopIteration
|---|---Warning
|---|---|---BytesWarning
|---|---|---DeprecationWarning
|---|---|---FutureWarning
|---|---|---ImportWarning
|---|---|---PendingDeprecationWarning
|---|---|---RuntimeWarning
|---|---|---SyntaxWarning
|---|---|---UnicodeWarning
|---|---|---UserWarning
|---GeneratorExit
|---KeyboardInterrupt
|---SystemExit

This also means that when defining your own exceptions you should base them off StandardError not Exception.

Base class for all standard Python exceptions that do not represent
interpreter exiting.
🌐
W3Schools
w3schools.com › python › python_ref_exceptions.asp
Python Built-in Exceptions
The table below shows built-in exceptions that are usually raised in Python.