Py2exe 将 tkinter 转换为 exe 时出错 - 'module' 对象没有属性 'tcldir'
Py2exe error converting tkinter to exe - 'module' object has no attribute 'tcldir'
我在使用 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.6
,我想您也在做同样的事情。我也遇到了这个问题,用 pyinstaller 解决了,可以使用 pip
安装。这完全支持 3.6 和以前的版本,但我更喜欢 --noconsole
参数,它没有显示标准 i/o window(所以你只能得到你的 tkinter
window)
编辑:
抱歉,刚刚查看了文件路径,发现您正在使用 python 3.4
。这可能意味着我的回答无关紧要:'(
我在使用 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.6
,我想您也在做同样的事情。我也遇到了这个问题,用 pyinstaller 解决了,可以使用 pip
安装。这完全支持 3.6 和以前的版本,但我更喜欢 --noconsole
参数,它没有显示标准 i/o window(所以你只能得到你的 tkinter
window)
编辑:
抱歉,刚刚查看了文件路径,发现您正在使用 python 3.4
。这可能意味着我的回答无关紧要:'(