Relative import with no known parent package

Hi,

I’m having trouble setting up an App with a tree structure. The strucutre of my app is currently;

Report-app
├── app
│ ├── image_entity
│ │ ├── init.py
│ │ ├── controller.py
│ ├── report
│ │ ├── init.py
│ │ ├── controller.py
│ ├── report_entity
│ │ ├── init.py
│ │ ├── controller.py
│ │ └── parametrization.py
│ │ └── report_helper.py
│ └── init.py
├── requirements.txt
└── viktor.config.toml

The error I’m getting is;

image

My init.py file looks like this;

from .report_entity.controller import Controller
from .report.reportcontroller import ReportEditorController
from .image_entity.imagecontroller import ImageController

Also having this issue with the controller in the report_entity folder, which currently looks like;

from .parametrization import *
from .report_helper import *

How do I resolve this issue?

Thanks

Hi Charlie,

I’m assuming you get this error when running viktor-cli start from the Report-app directory?
The init files should be called __init__.py with underscores, else they are considered a regular module.
Could you try to change the names of these files?

The folder structure of my app was incorrect. After fixing that up the initial method now works.

1 Like