使用 py2exe 为 Tkinter 程序创建单个 EXE [英] Creating single EXE using py2exe for a Tkinter program

查看:58
本文介绍了使用 py2exe 为 Tkinter 程序创建单个 EXE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to use minty's solution provided on this link to generate a single exe file for my Tkinter based program:

py2exe - 生成单个可执行文件

这是我在 setup.py 中写的:

Here's what I wrote in the 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 没有运行,也没有出现任何错误.如果我删除所有这些包含,它甚至不起作用.

It creates a 'tcl' folder for Tkinter stuff even though I have specified bundle_files = 1. Plus it also generates some other exe w9xpopen.exe. My actual exe, however, does not run, and it doesn't give any errors either. It doesn't even work if I remove all those includes.

对我在这里可能遗漏的东西有什么想法吗?我在 64 位 Windows 7 机器上工作.

Any thoughts on what I could be missing here? I'm working on a 64-bit Windows 7 machine.

推荐答案

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

Thanks to this link, you have to edit site-packages/py2exe/build_exe.py and add "tcl85.dll" and "tk85.dll" to the dlls_in_exedir list. This will get it to run, although you'll still have the tcl folders, and those two dlls will be there along-side the exe. But it's way better than 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"]

这篇关于使用 py2exe 为 Tkinter 程序创建单个 EXE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆