Loading modules from several directories

Eugene Pervago eugene at ulka.com
Wed Sep 18 10:07:18 EDT 2002

tebeka at cs.bgu.ac.il (Miki Tebeka) wrote in message news:<33803989.0209172247.2e6afc1f at posting.google.com>...
> Hello Eugene,
> Doesn't
> sys.path.append('/somedir/foo')
> sys.path.append('/somedir/foo/project_a')
> import foostuff
> import projectstuff
> works?
> Miki

The problem is with following:
>>> sys.path.append('/onedir/foo')
(where /onedir/foo/utils.py exists)
>>> sys.path.append('/anotherdir/project_a/')
(where /aotherdir/project_a/foo/bar.py exists)

>>> import foo.utils
>>> import foo.projectA.bar
ImportError: No module named projectA.bar

If I put the project_a path first, it loads its modules but can't
import the /onedir/foo modules. It seems package can only be in one
place, once Python finds it, it just stops looking elsewhere.

Eugene Pervago

More information about the Python-list mailing list