I am trying to do relative imports in Python
In Ruby, I can just
require '../puppies.rb'
But Python gets all weird when I try something similar.
My structure looks like this:
project/
lib/
something_awesome.py
bin/
exe.py
I want to import something_awesome.py
into exe.py
However:
from ..lib import something_awesome
results in,
Traceback (most recent call last): File "bin/exe.py", line 9, in <module>
from ..lib import something_awesome
ValueError: Attempted relative import in non-package
How do I do this? The only answers on Stack Overflow are of the "you're not supposed to do that" sort.
http://docs.python.org/2/tutorial/modules.html#intra-package-references ?
Looks like maybe you're missing an empty init.py file (a common gotcha).