Built-in Exceptions
ImportError — exception class
Signals a failure to import a module or requested member. ModuleNotFoundError specializes a missing module; an existing module without a requested export can raise ImportError. name and path can provide context; avoid swallowing errors from inside imported code. Catch ImportError when this category is the recovery boundary; do not rely on the exact human-readable message.
Formal Syntax & Structure
python syntaxpython
ImportErrorReturn Value
type
The class object ImportError; this reference documents the class identity, not a universal constructor signature.
Working Example
Example Snippetpython
try: from math import bytemind_missing_symbol_27except ImportError as error: print(type(error).__name__)