我已将我设计的python游戏转换为exe。运行exe本身会导致它闪烁然后关闭,这意味着发生了错误。从命令提示符下运行它会导致错误为好,但它记载:哪里把图像文件夹在Python的exe文件?
Cannot load image: Playfield.png
Couldn't open images\Playfield.png
这告诉我,load_image
块失败。我之前遇到过这个,当时我没有images
目录。
我试图将images
文件夹移动到dist
目录。这是显示的错误:
Traceback (most recent call last):
File "Table_Wars.py", line 728, in <module>
File "Table_Wars.py", line 51, in main
File "Table_Wars.py", line 236, in __init__
File "pygame\__init__.pyc", line 70, in __getattr__
NotImplementedError: font module not available
(ImportError: DLL load failed: The specified module could not be found.)
这是我第一次用py2exe,所以我不确定发生了什么事。原始python文件本身,Table_Wars.py,按预期运行。
如果有帮助,整个Table_Wars文件夹的位置位于我的桌面(C:\ Users \ Oventoaster \ Desktop \ Games \ Table_Wars)中名为Games的文件夹中。我正在运行Windows 7 32位操作系统。
根据要求,这里是我所产生的output.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
email
mime
encodings
logging
multiprocessing
dummy
pygame
threads
unittest
xml
parsers
temp
dist
images
这里是我以前的文件转换setup.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钻石的缩短的形式建议防止从寻找Table_Wars.py
py2exe:
从CMD:
running py2exe
*** searching for required modules ***
error: Table_Wars.py: No such file or directory.
setup
和Table_Wars
位于相同的目录中。如果有帮助,我输入python.exe和setup.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
你可以运行'树“C:\用户\ Oventoaster \桌面\游戏\ Table_Wars”> output.txt'和后期输出.txt文件显示出来了吗?这会让我们更好地了解文件的位置。 –
我认为它实际上只是你的py2exe安装文件的一个问题。你可以发布你的'setup.py'吗? – jdi
该问题与工作目录相关,可执行文件的启动位置?相对应该对齐到工作目录,以便正确解决。或者,如果可能的话,尝试在程序中连接图像的完整路径,然后您可以看到地球上的路径没有正确形成。 – zinking