python - 使用 py2exe 为 Tkinter 程序创建单个 EXE

标签 python tkinter py2exe

我正在尝试使用此链接上提供的 minty 解决方案为我基于 Tkinter 的程序生成单个 exe 文件:

py2exe - generate single executable file

这是我在 setup.py 中写的:

from distutils.core import setup
import py2exe, sys, os

sys.argv.append('py2exe')

setup(windows=[{'script': 'filename.py'}], \
            options={"py2exe": {"includes": ["decimal", "Tkinter", \
            "tkFileDialog", "csv", "xml.dom.minidom", "os"], \
            'bundle_files': 1, 'compressed': False}}, \
            zipfile = None)

即使我指定了 bundle_files = 1,它也会为 Tkinter 内容创建一个“tcl”文件夹。此外,它还会生成一些其他 exe w9xpopen.exe。但是,我实际的 exe 没有运行,也没有给出任何错误。如果我删除所有这些包含,它甚至都不起作用。

对我在这里可能遗漏的东西有什么想法吗?我正在使用 64 位 Windows 7 计算机。

最佳答案

感谢this link ,你必须编辑 site-packages/py2exe/build_exe.py 并将 "tcl85.dll""tk85.dll" 添加到dlls_in_exedir 列表。这将使它运行,尽管您仍然拥有 tcl 文件夹,并且这两个 dll 将与 exe 一起存在。但它比 bundle_files=3 好多了。

        self.dlls_in_exedir = [python_dll,
                               "w9xpopen%s.exe" % (is_debug_build and "_d" or ""),
                               "msvcr71%s.dll" % (is_debug_build and "d" or ""),
                               "tcl85.dll",
                               "tk85.dll"]

关于python - 使用 py2exe 为 Tkinter 程序创建单个 EXE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14975018/

相关文章:

python - wxPython - py2exe - exe 文件旧窗口

python - py2exe 64位python 2.7安装

python - 如何从父子目录导入模块

python - 附加一个空列表但被转换为 NoneType

由于 tclError,使用 tkinter 的 python 程序无法运行

python - 我可以在 Tkinter 中注册更改事件的回调吗?

python - PyInstaller/Py2exe - 在单文件编译中包含带有第三方脚本的 os.system 调用

python - 将 python 前瞻断言正则表达式转换为有效的 Golang

python - Pandas sqlalchemy create_engine 与 SQL Server Windows 身份验证的连接

python - 创建一个带有未知数量复选框的窗口 - Python/tkinter