我做了一個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