Py2exe构建可执行文件,没有例外。运行可执行文件时,会生成以下日志文件:
Traceback (most recent call last):
File "ecm2es_gui.py", line 10, in <module>
File "weblogin.pyo", line 4, in <module>
File "mechanize\__init__.pyo", line 122, in <module>
File "mechanize\_mechanize.pyo", line 14, in <module>
File "mechanize\_html.pyo", line 19, in <module>
File "mechanize\_form.pyo", line 64, in <module>
ImportError: No module named inspect
当我从Python Shell,Eclipse或Geany运行程序时,我没有错误,它运行正常。
我认为我的问题是安装了Mechanize或鸡蛋,但现在我认为这不是问题。
有什么想法吗? TIA - Brad
UPDATE ...这是我的setup.py文件:
from distutils.core import setup
import py2exe
import sys; sys.argv.append('py2exe')
includes = []
excludes = ['_ssl', 'pdb', 'unittest', 'inspect',
'pyreadline', 'difflib', 'doctest', 'locale',
'optparse', 'pickle', 'calendar', '_gtkagg',
'_tkagg', 'bsddb', 'curses', 'email', 'pywin.debugger',
'pywin.debugger.dbgcon', 'pywin.dialogs']
packages = []
dll_excludes = []
setup(
options = {"py2exe": {"compressed": 1,
"optimize": 2,
"bundle_files": 3,
"includes": includes,
"excludes": excludes,
"packages": packages,
"dll_excludes": dll_excludes,
"dist_dir": "dist",
"xref": False,
"skip_archive": False,
"ascii": False,
"custom_boot_script": '',
}
},
# zipfile = None,
name='EnerSave Uploader',
version='0.5',
description='Upload ECM-1240 Data to EnerSave',
author='Brad Norman',
windows=[{"script":"ecm2es_gui.py",
"icon_resources": [(1, "favicon.ico")]}
]
)
答案 0 :(得分:1)
错误是
ImportError: No module named inspect
在您的设置脚本中,您在排除列表中检查。将其从排除项中删除,py2exe会将其与您的可执行文件打包在一起,以便 mechanize 可以使用它。