Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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"

like image 409
Taylor Hetherington Avatar asked Oct 18 '22 13:10

Taylor Hetherington


1 Answers

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.

like image 102
Mahmoud Elshahat Avatar answered Oct 21 '22 08:10

Mahmoud Elshahat