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__.pyfile inapp? - Martijn Pieters♦__init__.pyin all the directories in the given file heirarchy - Hashkenimport app; print app.__file__say is the path to that module / package? - Martijn Pieters♦app.__file__givesapp/__init__.pyas output - Hashkenapp1.py. - Martijn Pieters♦