Viktor Danilov Viktor Danilov - 1 year ago 95
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.

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download