This is a small collection of Python errors I've encountered while learning.
I'm saving minimal examples and fixes as I go.
Each folder contains:
- reproduce.py
- fix.py
- README explanation
- Why does Python say "No such file or directory"? (FileNotFoundError)
- Why do I get "AttributeError: 'dict' object has no attribute 'append'"?
- Why can't Python find my module? (ModuleNotFoundError, example case)
- Why does Python say "list index out of range"? (IndexError)
- Why do I get "TypeError" when working with data? (common case)
- Why does json.loads() fail to parse my data? (JSON Errors)
- TypeError: 'NoneType' object is not subscriptable
- TypeError: list indices must be integers or slices, not str
- TypeError: 'int' object is not callable
- TypeError: can only concatenate str (not "int") to str
- TypeError: string indices must be integers
- TypeError: object of type 'int' has no len()
- TypeError: unhashable type: 'list'
- TypeError: 'int' object is not subscriptable
- TypeError: greet() missing 1 required positional argument
- TypeError: unsupported operand type(s) for +: 'int' and 'list'
- TypeError: write() argument must be str, not dict
- IndexError: list index out of range
- IndexError: tuple index out of range
- IndexError: list assignment index out of range
- IndexError: string index out of range
- AttributeError: 'list' object has no attribute 'add'
- AttributeError: 'NoneType' object has no attribute 'append'
- AttributeError: 'NoneType' object has no attribute 'split'
- AttributeError: 'tuple' object has no attribute 'append'
- AttributeError: 'str' object has no attribute 'append'
- AttributeError: 'int' object has no attribute 'append'
- AttributeError: 'dict' object has no attribute 'append'
- ModuleNotFoundError: No module named 'requests'
- ModuleNotFoundError: No module named 'numpy'
- ModuleNotFoundError: No module named 'yaml'
- ModuleNotFoundError: No module named 'pandas'
- FileNotFoundError: [Errno 2] No such file or directory
- PermissionError: [Errno 13] Permission denied
- PermissionError: [Errno 13] Permission denied: directory
- NotADirectoryError: Not a directory
- IsADirectoryError: expected file but got directory
- JSONDecodeError: Expecting value
- JSONDecodeError: Expecting property name enclosed in double quotes
- JSONDecodeError: Extra data
- TypeError: the JSON object must be str, bytes or bytearray
- UnicodeDecodeError: 'utf-8' codec can't decode byte (read_csv)
- ParserError: Error tokenizing data
- KeyError: column not found
- ValueError: Length mismatch
- IndexError: single positional indexer is out-of-bounds
- ValueError: invalid literal for int()
- ValueError: too many values to unpack
- ValueError: not enough values to unpack
- ValueError: could not convert string to float
- ValueError: could not convert string to float
More error cases will be added as I encounter them while learning Python.
- Contact Log:
TypeError,AttributeError - File Log Reader:
FileNotFoundError,PermissionError - User Data Processor:
ModuleNotFoundError,IndexError,TypeError - JSON Config Loader:
JSONDecodeError,KeyError,TypeError,ValueError