I try to import a variable from another module by relative import path. Alas, is gives me an error:
C:\Python35\python.exe D:/Projects/baka_proj/pack2/mod2.py
Traceback (most recent call last):
File "D:/Projects/baka_proj/pack2/mod2.py", line 1, in <module>
from ..pack1.mod1 import some_vars_to_import
SystemError: Parent module '' not loaded, cannot perform relative import
The project has such a structure:
proj_root
__init__.py (empty)
package1
mod1.py (here is a variable some_vars_to_import)
__init__.py (empty)
package2
mod2.py (here I try to import by relative path)
__init__.py (empty)
In mod2.py
I try to import a variable from mod1.py
:
from ..pack1.mod1 import some_vars_to_import
And it fails.
Can you tell me, what's wrong with my code?
P.S. https://www.sendspace.com/file/zwmx0v -- here is the project.