So first... my directory structure..
---script/execute.py
|
L---helper---foo.py
L-----bar.py
L--- __init__.py
Now, execute.py calls both foo and bar .py as
from helper.foo import some_func
I am trying to run this as:
python script/execute.py
But I am getting this import error
from helper.foo import some_func
Import error: No module named helper??
What am I missing (note that there is no init inside script folder??)?
Thanks
You should check out http://docs.python.org/2/tutorial/modules.html#packages
The "too long, didn't read" of it is that you need to have a file called __init__.py
in your helper directory, e.g.,
$ touch helper/__init__.py
The file can also contain Python code, but in the simplest form an empty file is ok.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With