0
folder1-
     script1.py
     folder2-
          script2.py
          script3.py  
     folder3-
          script4.py

script1.py imports script2.py which imports script3.py

So when i run python script1.py, in the script2.py i use the following command:

from . import script3.py

and then i am able to use any of the models of script3.py

Now i want to run script4.py which imports script2.py, but i am getting the following error

from . import script3
E   ImportError: attempted relative import with no known parent package   

How can this be resolved

I tried to create init.py files in both folder 1 and folder 2 but doesn't seem to work

  • 1
    Does this answer your question? [Relative imports for the billionth time](https://stackoverflow.com/questions/14132789/relative-imports-for-the-billionth-time) – Jorge Luis Mar 11 '23 at 08:37

0 Answers0