I am about at wits end with what should be an extremely simple issue. Here is the format of a simple example that I wrote to try to fix my problem. I have a folder top with __all__ = ["p1","p2"]
in __init__.py
. I then have sub-folders p1 and p2 with __init__.py
in both of them with __all__
again defined with the names of two simple module quick1 and quick 2 with quick1 in p1 and quick2 in p2. If I import top.p1.quick1 from a script outside of top then the import works fine. However, trying to import top.p1.quick1 from quick2 gives the error
File "quick1.py", line 1, in <module>
import top.p2.quick2
ImportError: No module named top.p2.quick2
How can I import a module from another sub-package? This is supposed to work according to the python documentation as far as I can tell. Does anyone see an obvious, trivial mistake that I made?
Edit: It appears that I need to add the directory with top to my search path. I can do this temporarily by setting PYTHONPATH. However, is there a better way to do this from a distutils script?