简体   繁体   中英

Python crashes when trying to compile using cx_Freeze

I'm trying to compile my python scripts using cx_Freeze, here is my setup file:

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
    )

But when I give the cmd command C:/python35/python.exe , it gets to copying C:\\python35\\python35.dll -> build\\exe.win-amd64-3.5\\python35.dll it pops up "python has stopped working"

This is crazy after hitting my head against the wall for the weird reason python crashes when I tried to build executable with cx_Freeze, what solved my problem is using ico format for icon file.

Your icon file should be icon type not png , may be because png is not supported by cx_Freeze.

In your setup.py change icon="icon.png" to icon="icon.ico" , please note the icon file must be in ico format, don't act smart and just change the extension.

If it still doesn't work you can give it a trial without writing this option at all icon="icon.png" and see if it works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM