I'm trying to import script1.py
from script2.py
but getting this error:
ImportError: attempted relative import with no known parent package
Parent_Dir/
__init__.py
Child1/
script1.py
Child2/
__init__.py
script2.py
I've tried a lot of ways to do this but none of them worked for me. This is what I've tried:
from .Child1 import script1
from ..Child1 import script1
from .Parent_Dir.Child1 import script1
from Parent_Dir.Child1 import script1
I know there are a lot of similar questions on SOF but most of them are either using sys
or os
or importlib
or PYTHONPATH
. Is there any way to do this without using any module and without using path
or PYTHONPATH
( I mean by using import statements only).