将我的python游戏编译为具有cx_Freeze的可执行文件

问题描述 投票:0回答:1

所以我最近在pygame中完成了我的第一场比赛,我想将其制作为可执行文件,以便可以将其发送给我的几个朋友进行尝试,但是事实证明,这比我想象的要难,建议我使用cx_Freeze软件包,但是我遇到了一些问题,请张贴我的设置代码和一些屏幕截图,希望有人比我聪明一些可以就此主题给我一些建议。

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']}})

错误:

cx_Freeze error

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

Game directory including all asset files and the setup.py

我希望任何人都知道该怎么做,可能还有其他更简便的选择,因为我一直在尝试了解它,但是似乎缺乏良好的指导,在此先感谢您的帮助,对不起我有点菜鸟。

python compiler-errors pygame exe cx-freeze
1个回答
0
投票

我会尝试pyinstaller。更容易使用。在主python文件的位置打开cmd提示符,然后运行以下命令:

pyinstaller pythonfile.py -F --onefile

它将为您提供一个.exe,您可以将其发送并用于运行游戏。

© www.soinside.com 2019 - 2024. All rights reserved.