python module_error official true

ImportError

ID: python/importerror

Also available as: JSON · Markdown
80%Fix Rate
95%Confidence
0Evidence

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active

Root Cause

An import statement failed. The module may not be installed, may have circular dependencies, or the import path is incorrect.

generic

Official Documentation

https://docs.python.org/3/library/exceptions.html

Workarounds

  1. 90% success pip install the missing package or add the correct path to sys.path
    pip install <package>  or  sys.path.insert(0, '/path/to/module')
  2. 90% success Check for circular imports and restructure to use lazy imports
    Move the import inside the function or use importlib

Dead Ends

Common approaches that don't work:

  1. Wrapping import in try/except and ignoring 80% fail

    Missing functionality causes confusing errors later