【问题标题】:REPL.IT: Python Pygame: How do you fix "pygame.error: No available audio device" Error? [closed]REPL.IT:Python Pygame:你如何修复“pygame.error:没有可用的音频设备”错误? [关闭]
【发布时间】:2020-05-04 05:37:52
【问题描述】:

我正在尝试在我的 Python Pygame 游戏中使用 Sounds,但它给了我这个错误:

Traceback (most recent call last):
  File "main.py", line 5, in <module>
    pygame.mixer.init()
pygame.error: No available audio device

我将如何解决这个问题?

*提前感谢您的帮助!

【问题讨论】:

标签: python pygame repl.it


【解决方案1】:

无法在 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

【讨论】:

    【解决方案2】:

    我假设您在 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
    

    【讨论】:

      猜你喜欢
      • 2020-10-17
      • 2021-01-30
      • 1970-01-01
      • 2022-12-31
      • 2015-12-08
      • 2017-08-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多