Module import problem

Gordon McMillan gmcm at
Mon Feb 28 19:30:37 EST 2000

Anthony DeLorenzo wrote:

> I'm having the dumbest problem trying to import a module.  I can't figure
> it out at all.  Basically, I'm on a win32 system.  The directory 
> \py152\lib is on my python path, and I'm trying to import the module
> \py152\lib\gadfly\
> So, I use this:
> import gadfly.gadfly

This only works if gadfly is a package. A package is a 
directory on sys.path that has an (which may be 
empty) in it. You could try adding an (empty) It 
will probably work.

Generally, if you're installing something that is not 
packagized, you should use a .pth file. E.g., if you unzipped 
gadfly to d:/chordate/gadfly, then you should create a file
with one line:

> And for some incomprehensible reason it doens't work.  I've used this 
> statement to import other modules in sub-folders, but it just won't
> work for this particular one.  Any ideas, because I'm stumped.  The 
> only way I can get it to import is by running python from the gadfly
> directory, so I do at least know that the module exists.
> Tony
> -- 
> # Anthony DeLorenzo <drgonzo at>
> #
> # mojo wire: 209-391-8932
> -- 

- Gordon

More information about the Python-list mailing list