Pythonexit code > 0

ImportError: cannot import name

$ImportError: cannot import name 'my_func' from 'my_module'

Analysis

Python found the module but cannot find the specific function or class you are trying to import from it.

Common Triggers

  • Circular imports (Module A imports B, and B imports A).
  • Typo in the function/class name.
  • Shadowing a standard library module with a local file (e.g., email.py).

Debug Checks

  • $Check for circular dependencies.
  • $Ensure you don't have a local file with the same name as a library.

Resolution

1
Refactor code to avoid circular imports.
2
Rename local files that conflict with standard libraries.