使用python和pygame使用cx_freeze创建.exe时出现问题,包括其他文件

jel*_*erg 0 python pygame cx-freeze

我在使用cx_Freeze创建.exe文件时遇到问题.我正在尝试使用这个需要一些.png,.gif和.ogg的Pygame游戏.我试图使用commmand行和setup.py来编译一个简单的Python(没有pygame或其他文件),但是既没有工作也没有我的死亡.

我已经安装了cx_Freeze并检查它是否与IDLE中的'import cx_freeze'一起使用而不会引发错误.我在Windows 7上使用Python 3.3,使用正确版本的pygame和cx_freeze作为我的python版本.

任何人都可以帮我创建这个.exe吗?

Ant*_*ony 5

要在您的文件中包含文件,.exe应该写一个setup.py与此类似的文件:

from cx_Freeze import setup, Executable

exe=Executable(
     script="file.py",
     base="Win32Gui",
     icon="Icon.ico"
     )
includefiles=["file.ogg","file.png",etc]
includes=[]
excludes=[]
packages=[]
setup(

     version = "0.0",
     description = "No Description",
     author = "Name",
     name = "App name",
     options = {'build_exe': {'excludes':excludes,'packages':packages,'include_files':includefiles}},
     executables = [exe]
     )
Run Code Online (Sandbox Code Playgroud)