我已经实现了一个名称为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