Pygame:pygame.error:无法打开文件.ogg

时间:2016-12-18 14:14:00

标签: python pygame python-3.5 ogg

OS X ver。 10.11.6;

Python3 ver。 stable 3.5.2 (bottled), devel 3.6.0rc1, HEAD(通过 Homebrew );

Pygame ver。 homebrew/python/pygame: stable 1.9.2a0, HEAD pip3 Homebrew 都会遇到同样的错误,我将在下面说明);

Xcode ver。Xcode 8.2 Build version 8C38

终端上运行:

python3 BattleCity.py

,其中 BattleCity.py 是游戏源代码,并在其中导入 pygame 模块。

以下是终端的结果:(为了便于阅读,我重新安排了缩进并添加/删除了一些不可见的字符)

2016-12-18 21:26:12.739 Python[1600:53113] 21:26:12.739
WARNING:140:
This application, or a library it uses, is using the deprecated Carbon Component
Manager for hosting Audio Units.

Support for this will be removed in a future release.

Also, this makes the host incompatible with version 3 audio units.

Please transition to the API's in AudioComponent.h.

Traceback (most recent call last):
  File "BattleCity.py", line 2074, in <module>
    game = Game()
  File "BattleCity.py", line 1266, in __init__
    sounds["start"] = pygame.mixer.Sound("sounds/gamestart.ogg")
pygame.error: Unable to open file 'sounds/gamestart.ogg'

我搜索了一些相关问题,但他们的解决方案不起作用。

在我使用pygame.init()的文件中,但仍然是同样的错误,所以我想知道上面的两个错误是否相关?

1 个答案:

答案 0 :(得分:0)

a post on Reddit我发现解决方案非常适合播放.ogg音乐文件。

如果您使用的是Homebrew,请在终端上输入以下内容: (在我运行以下代码之前,我会检查我是否在brew list)下面安装了任何代码

brew install libogg
brew install libvorbis
brew install sdl_mixer --with-libvorbis

如果你已经安装了sol_mixer,你的程序仍然无法正常工作(是的,它对我来说也没有),

尝试:

brew reinstall sdl_mixer --with-libvorbis
相关问题