在启动脚本上添加下面代码,指定根目录 import os import sys curPath = os.path.abspath(os.path.dirname(__file__)) rootPath = os.path.split(curPath)[0] print(curPath) sys.path.append(curPath) print(rootPath)
1. 两种方法都试试
curPath = os.path.abspath(os.path.dirname(__file__))
rootPath = os.path.split(curPath)[0]
sys.path.append(rootPath)
2.
curPath = os.path.abspath(os.path.dirname(__file__))
rootPath = os.path.split(curPath)[0]
print(curPath)
sys.path.append(curPath)
print(rootPath)