0

I have a nagging problem with importing modules I create. Although I can save them alright, when I open the Python shell to import it, it gives me this:

Traceback (most recent call last):   
File "<pyshell#0>", line 1, in <module>     
import draw ImportError: 
No module named 'draw'. 

This is very frustrating because I can run it directly from the file but when I want to import it, I get that error message.

glenn jackman
  • 238,783
  • 38
  • 220
  • 352
Dokua
  • 1
  • 5
  • 1
    what is your directory structure?? and check if you are missing a __init__.py inside your module directory – armak Sep 26 '16 at 11:36
  • @armak of course means `__init__.py` – PhilipB Sep 26 '16 at 11:45
  • @armak Thank you for the help but I'm very new to programming so please break it down into layman's terms for me. – Dokua Sep 26 '16 at 11:46
  • @Dokua you can refer to this http://stackoverflow.com/questions/15746675/how-to-write-a-python-module – armak Sep 26 '16 at 11:49
  • Every python package needs to have a `__init__.py` file. So if you got something like a classes subdirectory the parentfolder (where your script lays) has to have an init. You can then import it like `from .classes import ` – PhilipB Sep 26 '16 at 11:49
  • Thanks for the help! – Dokua Sep 26 '16 at 12:01

0 Answers0