I have a bare bones project structure with mostly empty python files for the sake of testing a concept from an online tutorial:
project|--package1| |--__init__.py| |--module1.py||--package2| |--__init__.py| |--module2.py||--__init__.py
module1.py:
from .package2.module2 import function2
module2.py:
def function2():return 0
Running module1.py directly results in this error:
Traceback (most recent call last):File "c:\"blahblahblah"\project\package1\module1.py", line 1, in <module>from .package2.module2 import function2
ImportError: attempted relative import with no known parent package
I've tried reducing the complexity of the issue by placing module2.py into the project folder itself and modifying the import as my tutorial suggests it would work (from .module2 import function2) but this yields the same error.
side note: I am under the impression the init files are unnecessary for my version of python, but I've added them to keep all my bases covered.
Python version 3.9.1
Any hints would be much appreciated.