How can I import a function in a script, where the function is defined in the parent's child folder?
In the following folder structure, I would like to use
root_folder/
utils_folder:
__init__.py
helper_functions.py (where Function_A is defined)
module_A_folder:
Script_A.py (Function_A will be imported and used here)
Script_A.py needs to use Function_A.
The __init__.py
of utils_folder
is defined:
from .helper_functions import Function_A
When I tried to import Function_A in Script_A.py
like this:
from ..utils import Function_A
I received the following error:
ImportError: attempted relative import with no known parent package
How can I make this work? I am with Python 3.9 x64.