close

[Solved] ImportError: cannot import name ‘…’ from partially initialized module ‘…’ (most likely due to a circular import)

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error ImportError: cannot import name ‘…’ from partially initialized module ‘…’ (most likely due to a circular import) in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How ImportError: cannot import name ‘…’ from partially initialized module ‘…’ (most likely due to a circular import) Error Occurs?

Today I get the following error ImportError: cannot import name ‘…’ from partially initialized module ‘…’ (most likely due to a circular import) in python.

How To Solve ImportError: cannot import name ‘…’ from partially initialized module ‘…’ (most likely due to a circular import) Error ?

  1. How To Solve ImportError: cannot import name '…' from partially initialized module '…' (most likely due to a circular import) Error ?

    To Solve ImportError: cannot import name '…' from partially initialized module '…' (most likely due to a circular import) Error I cannot have a file named retrying.py that is using the retrying package.

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

    To Solve ImportError: cannot import name '…' from partially initialized module '…' (most likely due to a circular import) Error I cannot have a file named retrying.py that is using the retrying package.

Solution 1

You have a circular import.

authentication/models imports corporate/models, which imports corporate/models/section, which imports authentication/models.

You can’t do that.

Solution 2

For future readers, this can also happen if you name a python file the same name as a dependency your project uses.

For example:

I cannot have a file named retrying.py that is using the retrying package.

Assuming I had the retrying package in my project, I could not have a file called retrying.py with the below contents:

from retrying import retry
print("HI")

A similar error with the message “most likely due to a circular import” would occur.

The same contents would work fine if I renamed the file to “retrying_example1.py”

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read