我试图使用py2exe和setup.py来编译我的程序,但每当我尝试控制台时都会给我这个:
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.exe setup.py py2exe
通过控制台运行setup.py看起来像这样:
来自distutils.core导入设置 导入py2exe
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"
]
请帮助,我不知道我在做什么。
谢谢
答案 0 :(得分:1)
您正在使用python 3进行编译。在python 3中,包是tkinter
,而不是Tkinter
答案 1 :(得分:0)
我没有足够的声誉来添加评论,但tkFiledialog错误类似于Tkinter&lt; - &gt; tkinter错误。在Python 3中,使用select top 1 ...
而不是import tkinter.filedialog
,如python 2.7