Search code examples
pythoncx-freeze

cx_Freeze not correctly converting python program(s) into executable


I have the following files for a project in pygame:

> extras.py

> main.py

> settings.txt

# main.py imports extras.py

I am trying to convert into an executable using cx_Freeze.

My setup.py file is as follows

from cx_Freeze import setup, Executable

executables = [Executable("main.py")]

setup(
    name = 'Pong',
    author = 'Ethan',
    options={
        "build_exe": {
            "packages":["pygame", "sys", "random"],
            "include_files":["settings.txt"]
            }},
    executables = executables,
    version = "5.1.1"
)

It builds without errors but upon running the exe it launches a window then immediately closes. I have gotten a single python file to build but can't figure out how to do multiple.


Solution

  • Use:

    executables = [Executable("main.py"), Executable("extras.py")]