Attempted relative import with no known parent package

你离开我真会死。 提交于 2019-12-01 16:44:56

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 .generate_holidays import generate_holidays. This syntax, however, tells Python that generate_holidays.py is part of a package, which wasn't the case. The error disappeared when I removed the period.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!