GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - go2maxi/common-python-errors: Minimal Python error examples with reproduce.py and fix.py. Built while learning.

BranchesTags
Open more actions menu

Latest commit

 

History

158 Commits
158 Commits

Folders and files

NameName
Last commit message
Last commit date
attributeerror-dict-object-has-no-attribute-append
attributeerror-dict-object-has-no-attribute-append
 
 
attributeerror-list-object-has-no-attribute-add
attributeerror-list-object-has-no-attribute-add
 
 
attributeerror-nonetype-append
attributeerror-nonetype-append
 
 
attributeerror-nonetype-object-has-no-attribute-split
attributeerror-nonetype-object-has-no-attribute-split
 
 
attributeerror-str-object-has-no-attribute-append
attributeerror-str-object-has-no-attribute-append
 
 
attributeerror-tuple-object-has-no-attribute-append
attributeerror-tuple-object-has-no-attribute-append
 
 
fileexistserror-file-exists
fileexistserror-file-exists
 
 
filenotfounderror-no-such-file-or-directory
filenotfounderror-no-such-file-or-directory
 
 
importerror-cannot-import-name-from
importerror-cannot-import-name-from
 
 
importerror-cannot-import-name-specific
importerror-cannot-import-name-specific
 
 
indentationerror-unexpected-indent
indentationerror-unexpected-indent
 
 
indexerror-list-assignment-index-out-of-range
indexerror-list-assignment-index-out-of-range
 
 
indexerror-list-index-out-of-range
indexerror-list-index-out-of-range
 
 
indexerror-string-index-out-of-range
indexerror-string-index-out-of-range
 
 
indexerror-tuple-index-out-of-range
indexerror-tuple-index-out-of-range
 
 
json-typeerror-the-json-object-must-be-str-bytes-or-bytearray
json-typeerror-the-json-object-must-be-str-bytes-or-bytearray
 
 
jsondecodeerror-expecting-property-name-enclosed-in-double-quotes
jsondecodeerror-expecting-property-name-enclosed-in-double-quotes
 
 
jsondecodeerror-expecting-value
jsondecodeerror-expecting-value
 
 
jsondecodeerror-extra-data
jsondecodeerror-extra-data
 
 
keyerror-dictionary-key-not-found
keyerror-dictionary-key-not-found
 
 
keyerror-missing-key-in-json
keyerror-missing-key-in-json
 
 
keyerror
keyerror
 
 
mini-projects
mini-projects
 
 
modulenotfounderror-local-module-not-found
modulenotfounderror-local-module-not-found
 
 
modulenotfounderror-no-module-named-numpy
modulenotfounderror-no-module-named-numpy
 
 
modulenotfounderror-no-module-named-pandas
modulenotfounderror-no-module-named-pandas
 
 
modulenotfounderror-no-module-named-requests
modulenotfounderror-no-module-named-requests
 
 
modulenotfounderror-no-module-named-yaml
modulenotfounderror-no-module-named-yaml
 
 
nameerror-name-is-not-defined
nameerror-name-is-not-defined
 
 
notadirectoryerror-errno-20-not-a-directory
notadirectoryerror-errno-20-not-a-directory
 
 
os-filenotfounderror-no-such-file-or-directory
os-filenotfounderror-no-such-file-or-directory
 
 
os-filenotfounderror-wrong-relative-path
os-filenotfounderror-wrong-relative-path
 
 
os-isadirectoryerror-expected-file-but-got-dir
os-isadirectoryerror-expected-file-but-got-dir
 
 
os-notadirectoryerror-not-a-directory
os-notadirectoryerror-not-a-directory
 
 
os-permissionerror-errno-13-permission-denied
os-permissionerror-errno-13-permission-denied
 
 
pandas-indexerror-single-positional-indexer-is-out-of-bounds
pandas-indexerror-single-positional-indexer-is-out-of-bounds
 
 
pandas-keyerror-column-not-found
pandas-keyerror-column-not-found
 
 
pandas-read-csv-parsererror-error-tokenizing-data
pandas-read-csv-parsererror-error-tokenizing-data
 
 
pandas-read-csv-unicodedecodeerror-utf-8-codec-cant-decode
pandas-read-csv-unicodedecodeerror-utf-8-codec-cant-decode
 
 
pandas-valueerror-length-mismatch
pandas-valueerror-length-mismatch
 
 
permissionerror-errno-13-permission-denied-directory
permissionerror-errno-13-permission-denied-directory
 
 
permissionerror-errno-13-permission-denied
permissionerror-errno-13-permission-denied
 
 
recursionerror-maximum-recursion-depth-exceeded
recursionerror-maximum-recursion-depth-exceeded
 
 
syntaxerror-invalid-syntax
syntaxerror-invalid-syntax
 
 
typeerror-can-only-concatenate-str-not-int-to-str
typeerror-can-only-concatenate-str-not-int-to-str
 
 
typeerror-int-not-subscriptable
typeerror-int-not-subscriptable
 
 
typeerror-int-object-not-callable
typeerror-int-object-not-callable
 
 
typeerror-list-indices-must-be-integers
typeerror-list-indices-must-be-integers
 
 
typeerror-missing-1-required-positional-argument
typeerror-missing-1-required-positional-argument
 
 
typeerror-nonetype-object-not-subscriptable
typeerror-nonetype-object-not-subscriptable
 
 
typeerror-not-supported-between-instances-of-str-and-int
typeerror-not-supported-between-instances-of-str-and-int
 
 
typeerror-object-of-type-int-has-no-len
typeerror-object-of-type-int-has-no-len
 
 
typeerror-string-indices-must-be-integers
typeerror-string-indices-must-be-integers
 
 
typeerror-unhashable-type-list
typeerror-unhashable-type-list
 
 
typeerror-unsupported-operand-type-int-and-list
typeerror-unsupported-operand-type-int-and-list
 
 
typeerror-unsupported-operand-types
typeerror-unsupported-operand-types
 
 
typeerror-write-argument-must-be-str-not-dict
typeerror-write-argument-must-be-str-not-dict
 
 
unboundlocalerror-local-variable-referenced-before-assignment
unboundlocalerror-local-variable-referenced-before-assignment
 
 
unicodedecodeerror-utf-8-codec-cant-decode-byte
unicodedecodeerror-utf-8-codec-cant-decode-byte
 
 
valueerror-could-not-convert-string-to-float
valueerror-could-not-convert-string-to-float
 
 
valueerror-invalid-literal-empty-string
valueerror-invalid-literal-empty-string
 
 
valueerror-invalid-literal-for-float
valueerror-invalid-literal-for-float
 
 
valueerror-invalid-literal-for-int
valueerror-invalid-literal-for-int
 
 
valueerror-not-enough-values-to-unpack
valueerror-not-enough-values-to-unpack
 
 
valueerror-too-many-values-to-unpack
valueerror-too-many-values-to-unpack
 
 
zerodivisionerror-division-by-zero
zerodivisionerror-division-by-zero
 
 
README.md
README.md
 
 

Repository files navigation

Common Python Errors

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

Common Questions

  • Why does Python say "No such file or directory"? (wrong path or working directory)
  • 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? (JSONDecodeError)
  • Why does Python say "No module named 'my_utils'" even though the file exists? (local module case)
  • Why do I get "TypeError: '>' not supported between instances of 'str' and 'int'?
  • Why does Python fail when I just press enter on input()?
  • Why does Python say "cannot import name" even though the module exists?
  • Why can't Python find my file even though it's in the same folder? (working directory issue) (relative path issue)

Error Archive

NameError

  • NameError: name '...' is not defined

UnboundLocalError

  • UnboundLocalError: local variable referenced before assignment

TypeError

  • 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
  • TypeError: '>' not supported between instances of 'str' and 'int'

IndexError

  • 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

  • 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: 'dict' object has no attribute 'append'

ImportError

  • ImportError: cannot import name '...' from '...'
  • ImportError: cannot import name 'squareroot' from 'math' (typo)

ModuleNotFoundError

  • ModuleNotFoundError: No module named 'requests' (package not installed)
  • ModuleNotFoundError: No module named 'numpy'
  • ModuleNotFoundError: No module named 'yaml'
  • ModuleNotFoundError: No module named 'pandas'
  • ModuleNotFoundError: No module named 'my_utils'

OS / File Errors

  • FileNotFoundError: No such file or directory (wrong path or working directory)
  • PermissionError: [Errno 13] Permission denied
  • PermissionError: [Errno 13] Permission denied: directory
  • NotADirectoryError: Not a directory
  • IsADirectoryError: expected file but got directory
  • FileNotFoundError: wrong relative path (same folder issue)

FileExistsError

  • FileExistsError: [Errno 17] File exists

JSON Errors

  • JSONDecodeError: Expecting value (empty or invalid JSON)
  • JSONDecodeError: Expecting property name enclosed in double quotes
  • JSONDecodeError: Extra data
  • TypeError: the JSON object must be str, bytes or bytearray

UnicodeDecodeError

  • UnicodeDecodeError: 'utf-8' codec can't decode byte

Pandas Errors

  • 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

SyntaxError

  • SyntaxError: invalid syntax

IndentationError

  • IndentationError: unexpected indent

KeyError

  • KeyError Guide
  • KeyError: 'age' (Python Dictionary)
  • KeyError: 'age' (JSON Data)

ValueError

  • ValueError: invalid literal for int() (non-numeric string)
  • ValueError: too many values to unpack
  • ValueError: not enough values to unpack
  • ValueError: could not convert string to float (non-numeric string)
  • ValueError: invalid literal for float() (non-numeric or malformed string)
  • ValueError: invalid literal for int() (empty input)

RecursionError

  • RecursionError: maximum recursion depth exceeded

ZeroDivisionError

  • ZeroDivisionError: division by zero

More error cases will be added as I encounter them while learning Python.


Related Mini Projects

  • Contact Log: TypeError, AttributeError
  • File Log Reader: FileNotFoundError, PermissionError
  • User Data Processor: ModuleNotFoundError, IndexError, TypeError
  • JSON Config Loader: JSONDecodeError, KeyError, TypeError, ValueError

About

Minimal Python error examples with reproduce.py and fix.py. Built while learning.

Topics

beginner-friendlydebuggingerror-handlinglearning-pythonpythonpython-errorstroubleshooting

Resources

Readme
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.