Python 3.4:py2exe未使用tkinter编译程序
我试图使用带有setup.py的py2exe编译我的程序,但每当我尝试时,控制台都会给出以下信息:Python 3.4:py2exe未使用tkinter编译程序,python,tkinter,py2exe,distutils,Python,Tkinter,Py2exe,Distutils,我试图使用带有setup.py的py2exe编译我的程序,但每当我尝试时,控制台都会给出以下信息: Traceback (most recent call last): File "setup.py", line 10, in <module> zipfile = None) File "C:\Python34\lib\distutils\core.py", line 149, in setup dist.run_commands() File "C:\Python34\
Traceback (most recent call last):
File "setup.py", line 10, in <module>
zipfile = None)
File "C:\Python34\lib\distutils\core.py", line 149, 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 164, in analyze
mf.import_hook(modname)
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 337, in
_find_and_load
raise ImportError(name)
ImportError: Tkinter
请帮忙,我不知道我在做什么
感谢您使用python 3编译。在python 3中,包是
tkinter
,而不是tkinter
,我没有足够的声誉来添加注释,但是tkFiledialog错误与tkinter-tkinter错误类似。在Python3中,您使用的是import tkinter.filedialog
,而不是Python2.7中的import tkFileDialog
,谢谢!但是现在它给了我:importorror:tkFileDialog
那么我现在该怎么办?@Egor.L:你现在该怎么办?您需要进一步研究tkinter在python 2和3之间的变化。
setup(window=[{'script': 'filename.py'}], \
options={"py2exe": {"includes": ["decimal", "Tkinter", \
"tkFileDialog", "csv", "xml.dom.minidom", "os"], \
'bundle_files': 3, 'compressed': False}}, \
zipfile = None)
excludes = ["pywin", "pywin.debugger", "pywin.debugger.dbgcon",
"pywin.dialogs", "pywin.dialogs.list",
"Tkconstants","Tkinter","tcl", "_imagingtk", "PIL._imagingtk",
"ImageTk", "PIL.ImageTk", "FixTk"
]