Viktor Danilov Viktor Danilov - 2 months ago 6x
Python Question

Cyclic import error

Whatever I try to import from my

app, I get an import error. For example:


from pupils.models import Pupils # => ImportError: cannot import name Pupils

I bet the path is right, PyCharm reads it. Everything imports fine from another apps by the way.


I guess you meet the cyclic imports problem.

An easy way to fix it is import Pupils later:

def where_you_need_pupils():
    from pupils.models import Pupils
    # do something