Question
Asked By – Puneet Shekhawat
from ..box_utils import decode, nms
This line is giving error
ImportError: attempted relative import with no known parent package
What is this error and how to resolve this error?
Now we will see solution for issue: Attempted relative import with no known parent package [duplicate]
Answer
Apparently, box_utils.py
isn’t part of a package. You still can import functions defined in this file, but only if the python script that tries to import these functions lives in the same directory as box_utils.py
, see this answer.
Nota bene: In my case, I stumbled upon this error with an import statement with one period, like this:
from .foo import foo
. This syntax, however, tells Python that foo.py
is part of a package, which wasn’t the case. The error disappeared when I removed the period.
This question is answered By – Tobias Feil
This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0