tl;dr How should I correctly use relative modules in PyDev?
If I use:
from . import myModule
I get the following error:
ImportError: attempted relative import with no known parent package
However...
If I just use:
import myModule
the project will run, but PyDev flags the line and file with
Unresolved Import: myModule
The package has an __init__.py
although its contents are empty
Edit: screenshot of PyDev Explorer structure added as requested by @Fabio Zadrozny
The problem is that it depends on how you run the script... by default PyDev will run the file directly, but in this case you want to run the file with -m <module-name>
.
PyDev can do that automatically if you go to PyDev > Run
and enable the related setting:
p.s.: either you have to use the relative import and launch with -m
or you can just use the full import (which in this particular case would be from pkg_BootMeUPY import in_constrains_ini as const
-- in which case it'd work regardless of how you launch the file).