我实现了一个名为myUtils的包,它由文件夹“myUtils”、文件“init.py”和许多名为“*.py”的文件组成!=“myUtils”。此软件包包含在myOtherProject.py当我从Eclipse运行它们时可以找到/使用它们。在
但是,当我运行py2exe时myOtherProject.py,结果exe找不到此模块(错误消息“ImportError:没有名为myUtils的模块”)。我的精简版安装程序.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上使用python2.7。在
将
sys.path.append()
行放在import
语句之前。更好的是,修改你的PYTHONPATH(我不知道如何在windows上实现这一点,但我相信Google可以告诉你如何做)我没有正确定义PYTHONPATH;分号后面有空格。而不是
这是必须的
^{pr2}$对于使用init.py定义的包(package MyPackage对应于一个文件夹MyPackage,其中包含init.py和一些其他文件,没有我的包.py)我不需要把路径加进去
但只是
。。。在
相关问题 更多 >
编程相关推荐