【问题标题】:Python crashes when trying to compile using cx_Freeze尝试使用 cx_Freeze 编译时 Python 崩溃
【发布时间】:2017-04-20 14:07:17
【问题描述】:

我正在尝试使用 cx_Freeze 编译我的 python 脚本,这是我的安装文件:

import cx_Freeze
import sys
import matplotlib
import os
base = None

if sys.platform == 'win32':
    base = "Win32GUI"

os.environ['TCL_LIBRARY'] = r'C:\\Python35\\tcl\\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\\Python35\\tcl\\tk8.6'

executables = [cx_Freeze.Executable("HomeScreen.py", base=base, 
icon="icon.png")]

cx_Freeze.setup(
    name = "LeagueBoost",
    options = {"build_exe":{"packages": ["sqlite3","requests","time","sys","os","statistics","matplotlib","random","collections"],
                            "include_files": ["Assets", "LeagueBoost_v1.py","LBRun.py","graphSetup.py","profilepage.py","Assets_rc.py"]}},
    version = "1",
    executables = executables
    )

但是当我给 cmd 命令C:/python35/python.exe 时,它到达copying C:\python35\python35.dll -> build\exe.win-amd64-3.5\python35.dll 它会弹出“python 已停止工作”

【问题讨论】:

    标签: python cx-freeze


    【解决方案1】:

    这太疯狂了 当我尝试使用 cx_Freeze 构建可执行文件时,由于奇怪的原因导致 python 崩溃,我的头撞到了墙上, 解决我的问题的方法是使用ico 格式的图标文件。

    你的图标文件应该是icon类型而不是png,可能是因为cx_Freeze不支持png

    在您的setup.py 更改 icon="icon.png"icon="icon.ico", 请注意,图标文件必须是ico 格式,不要聪明,只需更改扩展名即可。

    如果它仍然不起作用,您可以在不写此选项的情况下试用它icon="icon.png",看看它是否有效。

    【讨论】:

    • 我相信是 Windows,而不是 cx_Freeze,只支持 ico 文件作为应用程序图标。在 Wikipedia ICO (file format) 页面上,可以阅读:In Windows, all executables that display an icon to the user, on the desktop, in the Start Menu, or in Windows Explorer, must carry the icon in ICO format. 但是,我无法在“官方”Windows 文档中找到相应的声明。
    猜你喜欢
    • 1970-01-01
    • 2018-11-11
    • 1970-01-01
    • 2021-11-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-24
    相关资源
    最近更新 更多