I have seen these sites:
python relative import example code does not work
Relative imports for the billionth time
https://peps.python.org/pep-0328/
Python packages: relative imports
and loads more that I did not show, but they (The answers/The code) just don't work for some reason to relatively import other Python 'modules'. And for always, I have this forever-recurring error:
ImportError: attempted relative import with no known parent package
.
My directory structure looks like this:
program/
|_ main.py
|_ lib/
|_ __init__.py
|_ module1.py
|_ module2.py
|_ module3.py
In main.py:
from .lib.module1 import do_this
print('Imported')
In module1.py:
def do_this():
print('I did it')
I'm using Linux to do this, but it just doesn't work!!!
EDIT:
I don't want to have to do python3 -m <module> main.py
And apparently it still does not work without the dot.