使用cx_Freeze将pygame转换为exe

问题描述

我以前没有使用pygame的经验,但是通过遵循在线教程,我设法创建了Flappy Bird游戏。我想将脚本转换为.exe文件,以便与朋友共享。我创建了一个setup.py文件,如下所示:

import cx_Freeze
import os

executables = [cx_Freeze.Executable("script.py")]

assets = ['res/assets/' + each for each in os.listdir('C:/Users/MehmetSanisoglu/Desktop/Game/res/assets')]
sounds = ['res/sound/' + each for each in os.listdir('C:/Users/MehmetSanisoglu/Desktop/Game/res/sound')]
files = assets + sounds
files.append('res/04B_19.TTF') #Add the font file

cx_Freeze.setup(
    name="Flappy",options={"build_exe": {"packages":['pygame','sys','random'],"include_files":files}},executables = executables
)

但是,当我在script.py和setup.py所在的目录中运行cmd时,在创建的生成文件中找不到“ Flappy.exe”,但是有一个“ script.exe” ”。当我运行script.exe时,它会瞬间打开命令行,在其中可以看到以下几行:

running build
running build_exe
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html

,然后什么也没有发生。你能帮我吗? 谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)