Home > Blockchain >  PyDev: Python: Unresolved Import or ImportError: attempted relative import with no known parent pack
PyDev: Python: Unresolved Import or ImportError: attempted relative import with no known parent pack

Time:12-29

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

Setting to run with -m

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).

  • Related