【发布时间】:2018-01-10 01:35:41
【问题描述】:
我在使用 py2exe 将带有 tkinter 的 python3 脚本转换为 exe 时遇到问题。
没有 tkinter 程序成功转换为 exe。
我尝试过创建普通和捆绑的 exe,但每次都会抛出以下异常:
running py2exe
Traceback (most recent call last):
File "setup_py2exe_assist.py", line 14, in <module>
'bundle_files': 1,
File "C:\Python34\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Python34\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "C:\Python34\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Python34\lib\site-packages\py2exe\distutils_buildexe.py", line 188, in run
self._run()
File "C:\Python34\lib\site-packages\py2exe\distutils_buildexe.py", line 267, in _run
builder.analyze()
File "C:\Python34\lib\site-packages\py2exe\runtime.py", line 173, in analyze
target.analyze(mf)
File "C:\Python34\lib\site-packages\py2exe\runtime.py", line 74, in analyze
modulefinder.run_script(self.script)
File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 86, in run_script
self._scan_code(mod.__code__, mod)
File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 394, in _scan_code
self.safe_import_hook(name, mod, fromlist, level)
File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 138, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 120, in import_hook
module = self._gcd_import(name)
File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 274, in _gcd_import
return self._find_and_load(name)
File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 341, in _find_and_load
self._load_module(loader, name)
File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 372, in _load_module
self._add_module(name, mod)
File "C:\Python34\lib\site-packages\py2exe\dllfinder.py", line 209, in _add_module
self.hook(mod)
File "C:\Python34\lib\site-packages\py2exe\dllfinder.py", line 206, in hook
mth(self, mod)
File "C:\Python34\lib\site-packages\py2exe\hooks.py", line 259, in hook_tkinter
tcl_dir = os.path.normpath(os.path.join(fix.tcldir, ".."))
AttributeError: 'module' object has no attribute 'tcldir'
为了清楚起见,我想包括 tkinter。请帮助找出问题,因为我无法在任何地方找到解决此问题的方法。顺便问一下,有没有人和我一样的问题?
【问题讨论】:
-
或许可以试试其他转换器。甚至还有在线的。
标签: python-3.x tkinter py2exe