[Python] My cx_Freeze is giving an error. How do I fix this problem?

Discussão em 'Python' iniciado por Stack, Outubro 6, 2024.

  1. Stack

    Stack Membro Participativo

    I am trying to create an executable for my game, but it gives an error every time I try to start it. How can I fix it? I noticed that it might be the PNG image; the image is 320x32, and I don't know if that influences it. Please help me! T-T

    The error:

    cx_Freeze: Python error in main script
    Traceback (most recent call last):
    File
    C:\Users\com\AppData\Local\Packages\PythonSoftwareF
    oundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-pack
    ages\Python311\site-packages\cx_Freeze\initscripts\_startup
    _. py", line 141, in run
    module_init.run(f" __ main_{name}")
    File
    "C:\Users\com\AppData\Local\Packages\PythonSoftwareF
    oundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-pack
    ages\Python311\site-packages\cx_Freeze\initscripts\console.p
    y", line 25, in run
    exec(code, main_globals)
    File "DinoGame.py", line 27, in <module>
    FileNotFoundError: No such file or directory:
    'C:\Users\com\DinoGame\build\exe.win-amd64-3.11\lib\li
    brary.zip\Dino\Spritesheet.png'.


    And this is my setup.py:

    import cx_Freeze
    import os

    executables = [
    cx_Freeze.Executable(
    script="DinoGame.py",
    base="Win32GUI"
    )
    ]
    build_exe_options = {
    "packages": ["pygame", "os", "random"],
    "include_files": [
    (os.path.join(os.getcwd(), "Dino"), "Dino"),
    (os.path.join(os.getcwd(), "Musicas"), "Musicas")
    ],

    }
    cx_Freeze.setup(
    name="DinoGame",
    version="1.0",
    description="Jogo Dino feito por Gustavo Carvalho",
    options={"build_exe": build_exe_options},
    executables=executables
    )


    I tried changing the image folder, like moving the image to the Music folder, but the problem (ERROR) followed the image. I tried other codes for my setup.py, but it still didn't work. I also tried changing parts of my game related to the image or the image folder, and it still didn't work, and the error persisted.

    Continue reading...

Compartilhe esta Página