Observer <[EMAIL PROTECTED]> wrote: > >Hi, im a newbie both to python and this list. >I hope someone can help me whith this: > >I have a directory structure like this: >. >|-- src >| `-- pkg >| |-- __init__.py >| |-- main.py >| `-- spkg1 >| |-- __init__.py >| `-- config.py >`-- src2 > `-- pkg > |-- __init__.py > `-- spkg2 > |-- __init__.py > `-- config2.py > >and main.py is a python script that contains this imports: > >from pkg.spkg1 import config >from pkg.spkg2 import config2 > >executed in linux whith this: > >env PYTHONPATH=src:src2 src/pkg/main.py >Traceback (most recent call last): > File "src/pkg/main.py", line 4, in ? > from pkg.spkg2 import config2 >ImportError: No module named spkg2 > >changing the order of the python path only inverts the problem, is there >any way to solve this without changing the directory structure?
Nope. When Python goes to look for a package called "pkg", it starts at the beginning of PYTHONPATH and stops as soon as it finds one. You either need to use different names for the two packages (pkg1, pkg2), or use a symbolic link to link spkg2 into the src directory. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list