当前位置: 代码迷 >> 综合 >> python relative import
  详细解决方案

python relative import

热度:29   发布时间:2023-12-25 09:41:13.0
from .toolbox import get_logger

ModuleNotFoundError: No module named ‘main.toolbox’; ‘main’ is not a package

Reason: when you run with this file, the ‘.’ means main instead of current dir of file. so you can’t run file which contain ‘from . import ***’ or ‘from … import ***’ and so on.

about pycharm

if you want run a python file, you need mark the dir of this file as Source Root.

  相关解决方案