首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Pygame -未找到"Mixer“模块

Pygame -未找到"Mixer“模块
EN

Stack Overflow用户
提问于 2021-03-30 15:54:40
回答 1查看 302关注 0票数 2

我想用pygame在我的树莓派上播放音频文件。当我执行这段代码时:

代码语言:javascript
复制
import pygame
pygame.mixer.init()
pygame.mixer.music.load("/home/pi/Greetings/Welcome to the game.mp3")
pygame.mixer.music.play()

我得到一个错误:

代码语言:javascript
复制
  File "try.py", line 14, in <module>
    pygame.mixer.init()
  File "/home/pi/visionbeyond_test/env/lib/python3.7/site-packages/pygame/__init__.py", line 59, in __getattr__
    raise NotImplementedError(missing_msg)
NotImplementedError: mixer module not available (ImportError: libSDL2_mixer-2.0.so.0: cannot open shared object file: No such file or directory)

我多次尝试使用不同的解决方案来解决这个错误,但都无果而终。

以下是已安装的依赖项:

代码语言:javascript
复制
apt-cache search libsdl2
代码语言:javascript
复制
libsdl2-2.0-0 - Simple DirectMedia Layer
libsdl2-dev - Simple DirectMedia Layer development files
libsdl2-doc - Reference manual for libsdl2
libsdl2-gfx-1.0-0 - drawing and graphical effects extension for SDL2
libsdl2-gfx-dev - development files for SDL2_gfx
libsdl2-gfx-doc - documentation files for SDL2_gfx
libsdl2-image-2.0-0 - Image loading library for Simple DirectMedia Layer 2, libraries
libsdl2-image-dev - Image loading library for Simple DirectMedia Layer 2, development files
libsdl2-mixer-2.0-0 - Mixer library for Simple DirectMedia Layer 2, libraries
libsdl2-mixer-dev - Mixer library for Simple DirectMedia Layer 2, development files
libsdl2-net-2.0-0 - Network library for Simple DirectMedia Layer 2, libraries
libsdl2-net-dev - Network library for Simple DirectMedia Layer 2, development files
libsdl2-ttf-2.0-0 - TrueType Font library for Simple DirectMedia Layer 2, libraries
libsdl2-ttf-dev - TrueType Font library for Simple DirectMedia Layer 2, development files
libsdl2-2.0-0-dbgsym - debug symbols for libsdl2-2.0-0

我猜我特别需要安装libSDL2_mixer-2.0.so.0,但我尝试使用pip安装,但它找不到任何具有该名称的包。我正在使用一个虚拟环境的所有包,所以请让我知道,我可以尽快解决这个问题。

Python版本:3.7.3

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-03-30 21:58:24

经过大量的挖掘,我找到了适合我的解决方案。

只需执行以下命令:

代码语言:javascript
复制
apt-get install git curl libsdl2-mixer-2.0-0 libsdl2-image-2.0-0 libsdl2-2.0-0

我还是不明白它是怎么工作的,因为我已经有那些包了。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66866839

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档