1. 程式人生 > >python relative import

python relative import

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.