There's this app structure, where myapp
is the root directory and "app" and "package1" two parallel packages:
myapp
app
__init__.py
app.py
package1
__init__.py
my_file.py
__init__.py
*Note: the last __init__.py
is located in the root directory "myapp"
Now, in the app.py, if I try to import the my_file.py
from ..package1 import my_file as my_variable
Then I get this error:
ImportError: attempted relative import with no known parent package
I've researched and found a possible solution here:
How to resolve ImportError: attempted relative import with no known parent package
I'd like to apply the "Solution 1", but don't understand exactly where should I put the main.py and which would be its internal code or if, conversely, it could be an empty file like __init__.py