2
我有以下python structure directory structurePython的另一个脚本
在login_logout_test.py
我用下面的进口,当我运行此脚本一切工作正常调用脚本的时候输入模块(所有的模块正常进口)
import sys, os
parentPath = os.path.abspath("..")
if parentPath not in sys.path:
sys.path.insert(0, parentPath)
import common_test_functions as cts
from functions import login_logout_functions as llf
但是,当这个脚本(login_logout_test.py
)由CommandRunner.py
称为出现此错误:
No module named 'common_test_functions'
当脚本由CommandRunner.py调用时,父目录是相对于CommandRunner.py,不login_logout_test.py – EvanL00
的父目录我明白,但我想使脚本的输入以这种方式,** login_logout_test.py **本身运行正常或由** CommandRunner.py ** –
正确运行尝试使用一个点而不是两个 – EvanL00