gpt4 book ai didi

python - 使用 cx_freeze 时遇到问题

转载 作者:行者123 更新时间:2023-12-01 05:30:38 25 4
gpt4 key购买 nike

首先,技术方面: python :3.3CX_卡住:4.3.2我查看了几种设置,但一无所获。到目前为止,我只得到了一个非常快速关闭的 Python 命令行,叹息,没有 exe。setup.py:

from cx_Freeze import setup, Executable

executables = [
Executable("Swiss Rounds.py", appendScriptToExe=True, appendScriptToLibrary=False)
]

buildOptions = dict(
create_shared_zip = False)

setup(
name = "hello",
version = "0.1",
description = "the typical 'Hello, world!' script",
options = dict(build_exe = buildOptions),
executables = executables)

谢谢大家!

最佳答案

看来您忘记了可执行文件的基础,因此 cx freeze 不知道如何生成 exe。这就是我构建 setup.py 文件的方式。如果是 32 位,此设置会将 exe 放在不同的文件夹中。

import os, sys, platform
from cx_Freeze import setup, Executable

targetDir = "./build/"
build_exe_options = {
"icon": "/assets/images/icon.ico",
"build_exe": "/build/",
"packages": [],
"includes": ["re", "os", "atexit"],
"include_files": ["/assets/"],
"excludes": ["tkinter", "ttk", "socket", "doctest", "pdb", "unittest", "difflib",
"_bz2", "_hashlib", "_lzma", "_socket"],
"optimize": True,
"compressed": True,
}

is32bit = platform.architecture()[0] == '32bit'
if is32bit:
targetDir = "./buildX86/"
build_exe_options["build_exe"] = targetDir
# end

base = None
if sys.platform == "win32":
base = "Win32GUI"
# end

setup( name = "MyProgram",
version = "0.1",
description = "My program example",
options = {"build_exe": build_exe_options},
executables = [ Executable("/myprogram.py",
targetName="MyProgram.exe",
targetDir=targetDir,
base=base) ]
)

运行:

python setup.py build

关于python - 使用 cx_freeze 时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20361676/

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