[Tutor] adding a new folder to Python's importable modules search path
Dave Kuhlman
dkuhlman at rexx.com
Mon Nov 26 17:15:47 CET 2007
On Sun, Nov 25, 2007 at 11:14:47PM -0800, Jeff Younker wrote:
>
> > so when I run my script from the command line, the folder does seem
> > to be added to Python's importable modules search path. When I
> > attempt to import my_module I get the error:
> >
> > ImportError: No module named my_module
>
> Do your module directories have an __init__.py file
> in them?
Actually, you do not need an __init__.py file in directories that
are immediately in sys.path. You *do* need that __init__.py file
in sub-directories (which you access via dot notation). See:
http://docs.python.org/ref/import.html (and search for __init__)
Dave
--
Dave Kuhlman
http://www.rexx.com/~dkuhlman
More information about the Tutor
mailing list