我有一個模塊(Executive.py),我試圖導入到另一個模塊(ExecutiveTest.py)中。目錄結構如下所示:Python導入問題
src/
common/
python/
Executive.py
tests/
ExecutiveTest.py
在ExecutiveTest.py,我有以下行:
from common.Executive import Executive
我得到一個錯誤說:ImportError: No module named common.Executive
如何糾正這種錯誤的進口?
爲什麼你說「common.Executive」時,這不是模塊的路徑? – 2011-05-18 19:58:28
另請參閱軟件包文檔:http://docs.python.org/tutorial/modules.html#packages – 2011-05-18 19:59:38