Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
Lior Dolinski3,905 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 Keenan19,652 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 68,404 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!)