Lior Dolinski3,683 Points
ImportError: cannot import name ?
When i try to run one of the subclasses we've made using Import it failed..
from monster Import Troll import monster etc,
and i got a
Traceback (most recent call last): File "<input>", line 1, in <module> ImportError: cannot import name 'Troll'
the only thing that it did manage to import was the initial Monster class..
**im using PyCharm, python 3.5.2
what could be the problem for this?
i read something about circular import dependencies but couldn't figure exactly what that was and why did Kenneth had no problem with importing the subclasses..
Josh Keenan12,555 Points
Firstly check all spellings of stuff because that's the only reason stuff never works for me.
Could you post your code?
Chris FreemanTreehouse Moderator 51,421 Points
When I save your code to
models.py, then in the same directory create a file called
from models import Troll troll = Troll() print(troll.sound)
Then run it, I get:
$ python app.py growl
This seems like a PyCharm setup issue. It's not the editor I use. (Go Emacs!)