[Tutor] No module named 'module name' -- sub-folders?

Kent Johnson kent37 at tds.net
Mon Jan 26 00:10:46 CET 2009


On Sun, Jan 25, 2009 at 4:21 PM, spir <denis.spir at free.fr> wrote:

> I take the opportunity to ask a question about module lookup. I was *sure* that, when searching for a module, python automatically explores sub-folders (both of the current folder and of the pathes listed in PYTHONPATH). But this does not work by me (anymore):
> from ospyp.py, located in /home/spir/prog/ospyp, I cannot simply import wikilang which is in /home/spir/prog/ospyp/samples

No, Python does not automatically search subfolders of directories in
PYTHONPATH. It will search package folders and subfolders if you ask
it to. For example if your samples folder includes a file __init__.py
(marking it  as a package) then you can import samples.wikilang.

Kent


More information about the Tutor mailing list