问题
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.
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.
Can anyone assist me in creating this .exe?
回答1:
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]
)
来源:https://stackoverflow.com/questions/16065060/having-problems-with-making-an-exe-with-cx-freeze-with-python-and-pygame-inclu