繁体   English   中英

使用 cx_Freeze 将我的 python 游戏编译为可执行文件

[英]compiling my python game into executable with cx_Freeze

所以我最近在 pygame 中完成了我的第一款游戏,我想把它变成一个可执行文件,这样我就可以把它发给我的几个朋友尝试,但事实证明这比我想象的要难,我被推荐使用 cx_Freeze package ,但我遇到了一些问题,我发布了我的设置代码和一些屏幕截图,希望比我聪明的人能给我一些关于这个主题的建议。

安装程序.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 错误

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

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

我希望任何人都知道在这里做什么,并且可能有一个更简单的替代方案,因为我一直在尝试了解它,但似乎缺乏好的指南,提前感谢您的帮助,对不起,我很抱歉一个菜鸟。

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

pyinstaller pythonfile.py -F --onefile

它会给你一个.exe,你可以发送并使用它来运行游戏。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM