Relative Importe in Python 3
Posted: 11 Apr 2025, 19:35
Ich möchte eine Funktion aus einer anderen Datei im selben Verzeichnis importieren.from .mymodule import myfunction
< /code>
from mymodule import myfunction
< /code>
...but the other one gives me one of these errors:
ImportError: attempted relative import with no known parent package
< /code>
ModuleNotFoundError: No module named 'mymodule'
< /code>
SystemError: Parent module '' not loaded, cannot perform relative import
< /code>
Why is this?
< /code>
from mymodule import myfunction
< /code>
...but the other one gives me one of these errors:
ImportError: attempted relative import with no known parent package
< /code>
ModuleNotFoundError: No module named 'mymodule'
< /code>
SystemError: Parent module '' not loaded, cannot perform relative import
< /code>
Why is this?