Posted By: Anonymous
I’m trying to follow PEP 328, with the following directory structure:
pkg/ __init__.py components/ core.py __init__.py tests/ core_test.py __init__.py
core_test.py I have the following import statement
from ..components.core import GameLoopEvents
However, when I run, I get the following error:
tests$ python core_test.py Traceback (most recent call last): File "core_test.py", line 3, in <module> from ..components.core import GameLoopEvents ValueError: Attempted relative import in non-package
Is there anything I’m missing here?
Yes. You’re not using it as a package.
python -m pkg.tests.core_test