【发布时间】:2020-12-08 04:29:24
【问题描述】:
我主要使用 Tkinter 制作一个小游戏,但对于声音我使用了 pygame。
我一直在尝试创建一个 .exe 文件,但执行时它给了我一个错误。
pygame.init()
self.sound_player_shot = pygame.mixer.Sound('sounds/shot.wav')
self.sound_gameover = pygame.mixer.Sound('sounds/gameover.wav')
pygame.mixer.music.load('sounds/soundtrack.mp3')
pygame.mixer.music.play(-1)
这是我使用的pygame中唯一的代码,在创建.exe文件并将所有数据文件夹复制到dist文件夹后,执行该错误时发生:
Exception in Tkinter callback
Traceback (most recent call last):
File "tkinter\__init__.py", line 1883, in __call__
File "space_shooter.py", line 1292, in start_game
File "space_shooter.py", line 115, in __init__
pygame.error
sounds 文件夹与space_shooter.py 位于同一文件夹中,我所有其他较小的项目只需将所有数据文件夹复制到dist 即可工作。
谢谢!
【问题讨论】:
标签: python tkinter pygame exe pyinstaller