Pygame: pygame.error: Unable to open file .ogg

Pygame: pygame.error: Unable to open file .ogg

OS X 版本。 10.11.6;

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

Pygame 版本。 homebrew/python/pygame: stable 1.9.2a0, HEADpip3Homebrew 都会得到相同的错误,我将在下面说明);

Xcode ver.Xcode 8.2 Build version 8C38.

终端我运行:

python3 BattleCity.py

,which(BattleCity.py)是一个游戏源代码,pygame模块导入其中

以下是 Terminal 的结果:(为了便于阅读,我重新排列了缩进和 add/remove 一些不可见的字符)

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(),还是一样的错误所以我想知道上面两个错误是否相关?

来自 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