我做了一个py2exe可执行文件,这是一个“编程测验”。它是在pygame中制作的,当我将它作为EXE运行时,它一直运行到结束。我假设因为结尾有pygame文字。错误在下面。下面的代码的不作为exe文件,但作为一个正常的.py工作的部分:Py2Exe文件结束,可能是由于
def endgame():
global programmer
if programmer < 0:
programmer = 0
font = pygame.font.SysFont(None, 25)
text = font.render("You are: " + str(programmer) + "% a programmer.", True, black)
gameDisplay.blit(text, (170,200))
错误:
C:\Python27\Programming Survey\dist>survey.exe
survey.exe:43: RuntimeWarning: use font: DLL load failed: The specified module c
ould not be found.
(ImportError: DLL load failed: The specified module could not be found.)
Traceback (most recent call last):
File "survey.py", line 223, in <module>
File "survey.py", line 217, in main
File "survey.py", line 43, in endgame
File "pygame\__init__.pyc", line 70, in __getattr__
NotImplementedError: font module not available
(ImportError: DLL load failed: The specified module could not be found.)
调试这种东西的一种方法是从控制台运行.exe。而且,如果这不起作用,它只是创建一个新的控制台,只需在主代码周围使用'try:/ finally:'在末尾输入()',这样你就有机会看到什么它在窗户关闭之前打印出来。 – abarnert 2014-12-06 00:17:44
谢谢,发布错误 – HKVariant 2014-12-06 00:22:00
你从哪里得到PyGame,以及你是如何安装它的? – abarnert 2014-12-06 01:20:15