I am create a little package of packages to facilitate some work. The problem I am encountering is this error message ImportError: Attempted Relative Import With No Known Parent Package
. I have been googling around as to how to resolve this, but I have not found anything that works.
So here is the package structure. Notice that the applications are in these subfolders, and hey draw upon some modules that are at a higher level.
- Project_folder
- Callbacks
- PrintingCallback.py
- LoggingCallback.py
- DataModules
- preprocess.py
- utils.py
- app1
- app1.py
- app2
- app2.py
- app3
- app3.py
So the main action is in the app1.py
or app2.py
command line app. I am using the hydra
framework for the CLI. BUT, those python apps need to import the Callbacks
and DataModules
folder and the files in there. So how would I go about importing the preprocess.py
module into app1.py
? That is the real question.
I tried using an absolute path, like from Callback.LoggingCallback import LoggingCallback
, then then that still generated the error message ImportError: Attempted Relative Import With No Known Parent Package
. So is there a better way to do this that is reasonably pythonic?