python relative import

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_38689232/article/details/85223599
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.

猜你喜欢

转载自blog.csdn.net/qq_38689232/article/details/85223599