PlainError

ImportError: cannot import name from partially initialized module (most likely due to a circular import)

Last checked 2026-10-26 · 3 fixes · reviewed answer

TL;DRThis Python error occurs when one module tries to import something from another module that is still in the process of loading, usually because the two modules import each other in a loop.

Most likely cause: Circular import between two or more Python modules where each imports from the other before finishing initialization

Try first: Review the import statements in the files mentioned in the error

Likely causes

  1. Circular import between two or more Python modules where each imports from the other before finishing initializationmost likely
  2. Import statement placed at the top level that triggers loading of a dependent module too earlypossible

How to fix it

Safest first: SafeChanges settingsDangerous
  1. Review the import statements in the files mentioned in the errorSafe

    Open the Python files and look for any imports that reference each other directly or indirectly.

  2. Move imports inside functions or methods where possibleChanges settings

    Change top-level imports to local imports inside the functions that need them to break the cycle during module load.

  3. Restructure the code by moving shared code to a third moduleChanges settings

    Extract common functions or classes into a separate file that both original modules can import without creating a loop.

    ⚠ Back up your files before making structural changes.

If that didn't fix it

Trace the full chain of imports by adding print statements at the top of each module to see the loading order.

When to see a technician

Consult an experienced Python developer if the circular dependency cannot be resolved after reviewing the module structure.

Quick answers

What does ImportError: cannot import name from partially initialized module (most likely due to a circular import) mean?
This Python error occurs when one module tries to import something from another module that is still in the process of loading, usually because the two modules import each other in a loop.
What causes ImportError: cannot import name from partially initialized module (most likely due to a circular import)?
Circular import between two or more Python modules where each imports from the other before finishing initialization. (most likely) Import statement placed at the top level that triggers loading of a dependent module too early. (possible)
How do I fix ImportError: cannot import name from partially initialized module (most likely due to a circular import)?
Try these in order, safest first: 1. Review the import statements in the files mentioned in the error. 2. Move imports inside functions or methods where possible. 3. Restructure the code by moving shared code to a third module.
What if that didn't fix it?
Trace the full chain of imports by adding print statements at the top of each module to see the loading order.
When should I see a technician?
Consult an experienced Python developer if the circular dependency cannot be resolved after reviewing the module structure.
Did this fix it? Report a problem

Related errors

All Coding errors →