I have a number of Python files in a parent folder called 'API' and I'm trying to link them together:
API/auth/module1.py
API/subfolder/prgm.py
From the parent to the child folders, I have an init.py file containing paths or program names to call, however when I go to execute '/subfolder/prgm.py' that has a call to import 'module1.py', I get the following error at execution:
machine01% ./prgm.py
Traceback (most recent call last):
File "./prgm.py", line 2, in <module>
from API.auth.module1 import authFunction
ModuleNotFoundError: No module named 'API'
This is the import
statement I have in 'prgm.py':
from API.auth import module1
This question is a bit different from previous ones because I am trying to get a python script that is already in one sub-folder to access a module in another subfolder but under the same parent 'API' folder. Previous questions involved the python script being based in the parent folder and calling modules located in sub-folders.