简体   繁体   中英

compiling my python game into executable with cx_Freeze

So i recently finished my first game in pygame, and i wanted to make it into an executable so i can send it to a few of my friends to try, but this has proven harder than i thought, i was recommended to use the cx_Freeze package, but i have run into some issues, ill post my setup code and some screenshots, hopefully someone way smarter than me can give me some advice on this topic.

Setup.py:

from cx_Freeze import setup, Executable
setup( name = "Goblin Evader", version = "3.8",
       description = "A casual game made by mick breiting.",
       executables = [Executable("Goblin Evader.py",
                                 base = "Win32GUI")],
        options = {'build_exe': {'include_files': ['bg.jpg', 'L1.png', 'L1E.png', 'L2.png',
        'L2E.png', 'L3.png', 'L3E.png', 'L4.png', 'L4E.png', 'L5.png', 'L5E.png', 'L6.png',
        'L6E.png', 'L7.png', 'L7E.png', 'L8.png', 'L8E.png', 'L9.png', 'L9E.png', 'L10E.png',
        'L11E.png', 'R1.png', 'R1E.png', 'R2.png', 'R2E.png', 'R3.png', 'R3E.png', 'R4.png',
        'R4E.png', 'R5.png', 'R5E.png', 'R6.png', 'R6E.png', 'R7.png', 'R7E.png', 'R8.png',
        'R8E.png', 'R9.png', 'R9E.png', 'R10E.png', 'R11E.png', 'standing.png']}})

Error:

cx_Freeze 错误

Game directory including setup.py and all assets:

游戏目录,包括所有资产文件和 setup.py

I hope anyone knows what to do here, and possibly if there is an easier alternative for this, as i've been trying to learn about it but seem to fall short on good guides, thanks in advance for any help, and sorry im abit of a noob.

I'd give pyinstaller a try instead. Much easier to use. Open cmd prompt in the location of the main python file and run the following:

pyinstaller pythonfile.py -F --onefile

It will give you an.exe that you can send and use to run the game.

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