【发布时间】:2013-08-03 17:36:41
【问题描述】:
如果我尝试编译我的python(使用python 3.2)文件,会发生以下错误:
Traceback(most recent call last):
File
"c:\python32\lib\site-packages\cx_Freeze\initscripts\Console3.py", line
27, in <module>
exec(code, m.__dict__)
File "Abertura.py", line 208, in <module>
File "Abertura.py", line 154, in main
File "Abertura.py", line 9, in __init__
pygame.error: Couldn't open
C:\Python32\build\exe.win32-3.2\library.zip\Imagens\menu1.png
我已经包含了 pygame._view 并尝试将“Imagens”目录复制到 library.zip 文件,但它不起作用。我通过包含在我的代码中来使用来自其他目录的图像、音乐和视频:
def file_path(filename, directory):
return os.path.join(
os.path.dirname(os.path.abspath(__file__)),
directory,
filename
)
这是我的 setup.py 文件:
from cx_Freeze import setup, Executable
exe=Executable(
script="Abertura.py",
base="Win32Gui",
)
includefiles=[('C:\Python32\Imagens', 'Imagens'),
('C:\Python32\Musicas','Musicas'),
('C:\Python32\Videos','Videos')
]
includes=[]
excludes=[]
packages=[]
setup(
version = "1.0",
description = "RPG",
author = "Pedro Forli e Ivan Veronezzi",
name = "Batalha Inapropriada",
options = {'build_exe': {'excludes':excludes,'packages':packages,'include_files':includefiles}},
executables = [exe]
)
我该如何解决? (对不起我可能的英语错误)
【问题讨论】:
-
您是从 zip 文件运行它们吗?如果是这样,这可能就是问题所在。尝试从将所有外部文件和目录复制到其中的文件夹中运行它。
-
我不是,exe文件试图从library.zip文件中提取图像、视频和音乐。
标签: python-3.x pygame cx-freeze