【发布时间】:2023-03-19 02:23:01
【问题描述】:
我有以下简单的代码:
import pygame
pygame.init()
pygame.display.init()
pygame.display.set_mode((600, 600))
pygame.mixer.music.load('menu.mp3')
pygame.mixer.music.play(0)
is_running = True
while is_running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
is_running = False
当我在 cmd 中编译它时它工作正常。但是当我使用pyinstaller 将此脚本转换为 .exe 文件时,我遇到了未定义的问题。当我启动转换后的 .exe 文件时,我从 pygame 收到以下错误:
Traceback (most recent call last):
File "test.py", line 7, in <module>
pygame.mixer.music.load('menu.mp3')
pygame.error
[5208] Failed to execute script test
它发生了什么?
UPD:.exe 文件和menu.mp3 在同一目录中。
【问题讨论】:
标签: python pygame pyinstaller