A complete library of common Python errors. Click on any error to see the cause, the fix, and AI-powered solutions.
This TypeError occurs when you use the + operator between a string and a non-string (like an integer, float, or list). Python does not auto-convert types, so you must wrap the non-string with str(), or use an f-string.
ModuleNotFoundError means Python cannot find the package you tried to import. The three common causes are: the package is not installed, you are in a different virtual environment, or the module name is misspelled.
This AttributeError means you are calling a method or property on a value that is None. Find out why the variable became None — usually a failed lookup, a function without a return statement, or an uninitialized attribute — rather than masking it with a default.
NameError means Python cannot find a variable or function name in the current scope. The most common causes are a typo, using a variable before it is defined, or referencing an outer-scope name that is not accessible inside a function.
IndentationError: unexpected indent means a line has more leading whitespace than Python expects at that point. This almost always happens when you mix tabs and spaces, or when you accidentally indent a line that should be at the top level.
IndexError: list index out of range means you accessed an element at a position that does not exist. Lists are 0-indexed, so a list with 3 elements has valid indices 0, 1, and 2 — accessing index 3 raises IndexError.
KeyError means you tried to access a dictionary key that does not exist. Use dict.get(key, default) if the key is optional, or check 'key in dict' first if you need to distinguish missing from present-but-None.
ImportError: cannot import name X means Python found the module Y but could not find the name X inside it. The usual causes are a typo, a circular import, or a library version mismatch.
ValueError: too many values to unpack occurs when the right side of an unpacking assignment yields more items than the left side expects. Fix by adjusting the number of targets, using *rest to capture extras, or indexing the iterable directly.
SyntaxError: invalid syntax means Python could not parse your code at all. The most common causes are a missing colon after if/for/def/class, mismatched brackets, or using = instead of == for comparison.
FileNotFoundError means Python's open() could not find the file at the path you specified. The most common cause is a relative path that resolves against the current working directory, not the script's folder.
ZeroDivisionError occurs when you divide by a number that evaluates to zero. Guard the divisor with an if check, or wrap the division in try/except, or use math.isclose to treat near-zero values as zero.
This error occurs when you try to assign fewer values from an iterable (like a list or tuple) to more variables than it contains. For example, trying to unpack a list with 1 item into 2 variables.
This error happens when you use the .group() method on a Regular Expression match object, but the pattern didn't actually match anything. When re.search() or re.match() fail, they return None, and None has no .group() method.
Paste your full traceback into our AI tool and get an instant fix.