Leon
Leon

Reputation: 6544

Import in Python 3

structure:

app
app/__init__.py
app/mymodule.py
app/myscript.py

mymodule.py:

class One: pass

myscript.py:

from .mymodule import One

And I see an error:

SystemError: Parent module '' not loaded, cannot perform relative import

Why? I read this and this, but I cant understand, how to fix it. Please, explain me. Thanks.

Upvotes: 1

Views: 264

Answers (1)

DhruvPathak
DhruvPathak

Reputation: 43225

from .mymodule import One needs to be from mymodule import One ( remove the dot)

Upvotes: 1

Related Questions