Inside packagetest/, I have these four files:
__init__.py:class TestError(Exception): pass__main__.py:from . import TestError from .abc import defgh from .ijk.lmn import opqabc/__init__.py:def defgh(): passijk/lmn.py:def opq(): pass
When running __main__.py, I get this error:
File "D:\packagetest_main_.py", line 1, in
from . import TestError
ImportError: attempted relative import with no known parent package
Why does from . import TestError generate an error here?
How to solve this problem here and modify the code as little as possible?
I've already read Relative imports in Python 3 but I don't see how to modify my code here to make it work.