Refer to a Module within the Module in Python
I have a directory structure for a module like the following:
- foo
- __init__.py
- gui.py
I use the foo module from other places. Now I want to use something from the foo module in gui.py, but when I try to, I get this:
jsternberg@aquila:~$ python foo/gui.py
Traceback (most recent call last):
File "foo/gui.py", line 3, in <module>
import foo
ImportError: No module named foo
How do I get the foo module from ins开发者_Python百科ide of it?
The directory containing foo/
isn't in sys.path
when you invoke it that way.
python -m foo.gui
精彩评论