使用cx_freeze和python和pygame制作.exe时遇到问题,包括其他文件 [英] Having problems with making an .exe with cx_freeze with python and pygame, including additional files
问题描述
我无法使用cx_Freeze创建.exe文件。我正在尝试使用此 Pygame游戏,该游戏需要一些.png,.gif和.ogg跑步。我试图使用commmand行和setup.py来编译一个简单的Python(没有pygame或其他文件),但是都没有用,我有点死了。
I'm having trouble creating an .exe file with cx_Freeze. I'm trying to use this Pygame game which needs some .png's, .gif's and .ogg's to run. I have tried to compile a simple Python only (no pygame or additional files) using the commmand line and a setup.py, but neither worked and I'm a bit out of my death.
我已经安装了cx_Freeze并检查了它是否与IDLE中的 import cx_freeze一起使用,没有抛出错误。我正在Windows 7上使用Python 3.3,并将pygame和cx_freeze的正确版本用于我的python版本。
I have installed cx_Freeze and checked it worked with ''import cx_freeze' in the IDLE not throwing an error. I'm using Python 3.3 on Windows 7 with the correct versions of pygame and cx_freeze for my python version.
有人可以协助我创建此.exe吗?
Can anyone assist me in creating this .exe?
推荐答案
要在 .exe
中包含文件,应编写<$ c $类似于以下文件的c> setup.py 文件:
To include files in your .exe
you should write a setup.py
file that is similar to this:
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]
)
这篇关于使用cx_freeze和python和pygame制作.exe时遇到问题,包括其他文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!