Reputation: 877
I though it was easy, but I just can't do it. I read in the doc that this should work :
a/__init__.py
#nothing here
a/b.py
var = "hello world"
a/c.py
import b
print(b.var)
From .
:
>>> import a.c
ImportError: No module named 'b'
But it does not… What have I forgotten ? Is it because I use Python 3 ?
Upvotes: 0
Views: 447
Reputation: 4006
yes, it's because of Python3.
In Python 3, implicit relative imports within packages are no longer available
Changes in import statement python3
Upvotes: 1
Reputation: 1
Never mind that, I believe you should save your file in Program Files (x86)/Lib to create a new module, well that is for Python 2.7.6, but it is very possible it will work too for Python 3.0.
Upvotes: 0