我已经把我设计的python游戏转换成了一个exe。运行exe本身会导致它闪烁然后关闭,这意味着发生了错误。从命令提示符运行它也会导致错误,但会记录它:Cannot load image: Playfield.png
Couldn't open images\Playfield.png
这说明load_image块失败了。我以前没有images目录时遇到过这种情况。在
我试图将images文件夹移到dist目录。这是显示的错误:
^{pr2}$
这是我第一次使用py2exe,所以我不太确定发生了什么。原始python文件本身,表_战争.py,按预期运行。在
如果有帮助的话,整个Table_Wars文件夹的位置在我的桌面上的一个名为Games的文件夹中(C:\Users\Oventoaster\Desktop\Games\Table_Wars)。我运行的是Windows7 32位操作系统。在
如有要求,这是输出.txt我产生了:Folder PATH listing for volume OS
Volume serial number is 7659-4C9C
C:\USERS\OVENTOASTER\DESKTOP\GAMES\TABLE_WARS
build
bdist.win32
winexe
bundle-2.7
collect-2.7
ctypes
distutils
mime
encodings
logging
multiprocessing
dummy
pygame
threads
unittest
xml
parsers
temp
dist
images
这是设置.py我曾经转换文件:from distutils.core import setup
import py2exe
setup(console=['Table_Wars.py'])
编辑:我尝试使用完整的py2exe示例。这将创建exe,但给出相同的Cannot load image错误。试图将images文件夹与exe放在同一个文件夹中会创建一个Runtime Error: The application requested the runtime to terminate it in an unusual way.
Slace Diamond建议的代码缩写形式阻止了py2exe找到Table_Wars.py:
从命令:running py2exe
*** searching for required modules ***
error: Table_Wars.py: No such file or directory.
setup和{}在同一目录中。如果有帮助,我输入完整的路径python.exe以及设置.py. 在
编辑:我好像越来越近了。我把images目录放在self.extra_datas中,现在我得到了:
Fatal Python error: (segmentation fault)This application has requested the runtime to terminate it in an unusual way. Please contact the application's suppourt team for more information