gpt4 book ai didi

python - 无法让 Py2exe 正确编译为一个 exe

转载 作者:太空宇宙 更新时间:2023-11-03 18:06:30 27 4
gpt4 key购买 nike

嗨,我正在尝试创建一个执行我的 python 代码的 exe 文件。

如果我使用以下设置进行沼泽标准编译:

from distutils.core import setup
import py2exe, sys, os, Tkinter, ttk, collections, itertools

setup(
windows = [{'script': "sortSimi.py"}],
)

效果很好。除了 Dist 文件夹巨大且笨重这一事实之外。如果我随后尝试使用以下安装文件,以便将其编译为一个 exe:

from distutils.core import setup
import py2exe, sys, os, Tkinter, ttk, collections, itertools


setup(
options = {'py2exe': {'bundle_files': 1, 'compressed': True}},
windows = [{'script': "sortSimi.py"}],
zipfile = None,
)

它可以编译,但当我运行 exe 时,它​​只是挂起。我检查过任务管理器。它运行大约 10 秒,然后就消失了。屏幕上没有出现 GUI 或任何内容。

出了什么问题?

编辑:如果我将“windows”行更改为:

  console = ["sortSimi.py"]

然后它将打开一个cmd窗口,然后通知我程序没有响应。我还尝试使用带有“-b 1”参数的第一个安装文件从命令行而不是安装文件调用捆绑,同样的问题。

最佳答案

bundle_files = 1 在很多情况下都不能很好地工作。

我使用 bundle_files = 2 并定义 zipfile = r'lib\library.zip',然后使用 InnoSetup 将所有内容打包到一个文件安装程序中。

如果大小是一个问题,那么您可能需要定义 excluded = []dll_excludes = [] 列表。

关于python - 无法让 Py2exe 正确编译为一个 exe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26783192/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com