SystemError: Parent module ” not loaded, cannot perform relative import [duplicate]

I had the same problem and I solved it by using an absolute import instead of a relative one.

for example in your case, you may write something like this:

from app.mymodule import myclass

You can see in the documentation.

Note that relative imports are based on the name of the current
module. Since the name of the main module is always “__main__“,
modules intended for use as the main module of a Python application
must always use absolute imports.

Edit: If you encounter this error ImportError: No module named 'app.app'; 'app' is not a package, remember to add the __init__.py file in your app directory so that the interpreter can see it as a package. It is fine if the file is empty.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)