我已經實現了一個名稱爲myUtils的包,它由文件夾'myUtils',文件'init .py'和一些名稱爲* .py的文件組成! ='myUtils'。這個包包含在myOtherProject.py中,當我從Eclipse運行它時可以找到/使用它。py2exe ImportError:沒有名爲<package的模塊我已經執行了命令>
但是,當我在myOtherProject.py上運行py2exe時,導致exe無法找到此模塊(錯誤消息「ImportError:no module named myUtils」)。我的setup.exe修剪版本:
from distutils.core import setup
import py2exe, sys
sys.path.append(pathTo_myUtils)
import myUtils # this line works fine even if I comment out sys.path.append(...)
data_files_ = (('.', ["C:\\Python27\\DLLs\\MSVCP90.dll",
"C:\\Python27\\lib\\site-packages\\Pythonwin\\mfc90.dll"]))
setup(windows=['myOtherProject.py'], options={'py2exe': {'excludes': ['tcl'], 'includes': ['myUtils'], 'dll_excludes': ['tk85.dll', 'tcl85.dll'] }}, data_files=data_files_)
我該如何解決這個問題?我在WinXP上使用Python 2.7。
我有這個問題,因爲我試圖使用相對導入(對同一包中的其他模塊)。你解決了問題,但由於某些原因,我無法指定一個不同的'腳本'路徑選項,py2exe腳本必須位於軟件主腳本所在的位置。 – ecoe