I want to have this structure for my project:
requirements.txt README.md .gitignore project/ __init__.py project.py core/ __init__.py base.py engines/ __init__.py engine1.py engine2.py utils/ __init__.py refine_data.py whatever.py
The application starts from project/project.py . However, I constantly get import errors when using relative or absolute imports.
Both engines must be imported from project.core.base , utils must be imported from project.core.base , and project.py (main file) must be able to import from engines .
Absolute import does not work:
which gives an error:
ImportError: No module named project.core.base
But if I try relative imports instead
I get:
ValueError: Attempted relative import beyond toplevel package
I have seen other projects on Github structured in a similar way, but this seems to cause all kinds of problems. How can I make this work?
source share