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