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! While you're at it, check out some resources Treehouse students have shared here.

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

Python Object-Oriented Python (retired) Objects Creating Instances

Error while importing 'Monster class' in PyCharm

I created new class in PyCharm and tried to run it in shell but I get an error:

>>> from monster import Monster
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0.6\helpers\pydev\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
ImportError: No module named 'monster'

I also changed directory to be sure it's not causing error. What's wrong?

2 Answers

I think I understand this error. I'm confused because in video Kenneth said that every class is treated by Python as library but it doesn't seem to work this way in my IDE.

Solution found. I didn't know that I need init.py file in directories I want to import from. Now everything is clear.