BASE_DIR 在入口文件中设置项目目录为模块查找的目录 import sys,os BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(BASE_DIR)