python
module_error
official
true
ImportError
ID: python/importerror
80%Fix Rate
95%Confidence
0Evidence
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 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.
genericOfficial Documentation
https://docs.python.org/3/library/exceptions.htmlWorkarounds
-
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')
-
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:
-
Wrapping import in try/except and ignoring
80% fail
Missing functionality causes confusing errors later