I've been struggling with imports in my package for the last hour. In the last hour , I have been struggling for the import in my bag .
I've got a directory structure like so: I have a directory structure like this :
main_package | | __init__.py | folder_1 | | __init__.py | | folder_2 | | | __init__.py | | | script_a.py | | | script_b.py | | folder_3 | | __init__.py | | script_c.py
I want to access code in script_b.py
as well as code from script_c.py
from script_a.py
. I want to visit script_b.py
Code in and from script_c.py
Of script_a.py
Code .How can I do this? What should I do ?
If I put a simple import script_b
inside script_a.py
, when I run If I were in script_a.py
Put a simple import script_b
script_a.py
, When I run
from main_package.folder_1.folder_2 import script_b
I am met with an I met a
ImportError: no module named "script_b"
For accessing script_c.py
, I have no clue. For the visit script_c.py
, I don't know .I wasn't able to find any information about accessing files two levels up, but I know I can import files one level up with I can't find any information about accessing the upper two levels of files , But I know that I can import a higher level file
from .. import some_module
How can I access both these files from script_a.py
? How to go from script_a.py
Access these two files ?