Reputation: 11644
I am looking for a systematic approach to dealing with "cannot import name" errors in python. I would like to know
I know cyclic imports are a common cause, but there seem to be others as well.
Upvotes: 1
Views: 1913
Reputation: 1121864
The traceback is the one way to determine if an import is cyclical.
The other possibility is that the name doesn't exist in the imported module. You either misspelled the name, or you imported a different module from what you expected. Diagnose by running:
import module
print module.__file__
to check if you got the right module. Use dir(module)
to check what names it defines.
Upvotes: 2