2 回答
TA贡献1887条经验 获得超5个赞
播放音频在 Repl.IT 上不起作用,因为代码在服务器上运行,该服务器与您计算机的扬声器没有连接。
这是输出,当我重现您的错误时:
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
ALSA lib confmisc.c:767:(parse_card) cannot find card '0' <--- ALSA can not find the card
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM default
ALSA lib confmisc.c:767:(parse_card) cannot find card '0' <--- ALSA can still not find it
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM default
Traceback (most recent call last):
File "main.py", line 3, in <module>
pygame.mixer.init()
pygame.error: No available audio device
exit status 1
请参阅https://repl.it/talk/ask/Pygame-Audio-Issues/12147。
TA贡献1856条经验 获得超5个赞
我假设您在 Linux 环境中工作,因此,我建议您安装以下必备库:-
libSDL-1_2
libSDL_devel
libSDL_image-1_2
libSDL_mixer-1_2
libSDL_ttf-2
在 ubuntu 中,您可以使用以下行
sudo apt-get install libsdl1.2-dev libsdl-image1.2 libsdl-mixer1.2 libsdl-ttf2.0
添加回答
举报