This is my package hierarchy
app
|--__init__.py //Empty file
|--server.py
|--global_vars.py
|
|--handlers
|--__init__.py //Empty file
|
|--url1
| |--__init__.py //Empty file
| |--app1.py
| |--app2.py
|
|--url2
|--__init__.py //Empty file
|--app3.py
Now I want to import global_vars.py
inside app1.py
.
So I gave
import app.global_vars.py
inside app1.py.
But I get the following error:
import app.global_vars
ImportError: No module named app.global_vars
I should also mention that I am importing app1.py from server.py. server.py
is the file I am actually running. When server.py imports app1.py, app1.py
tries to import global_vars.py
and I get the above mentioned error
What am I doing wrong here?
__init__.py
file inapp
?__init__.py
in all the directories in the given file heirarchyimport app; print app.__file__
say is the path to that module / package?app.__file__
givesapp/__init__.py
as outputapp1.py
.