Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
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,527 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 67,995 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!)