游戏机:pygame.error.错误:无法打开文件.ogg

2024-06-25 23:16:49 发布

您现在位置:Python中文网/ 问答频道 /正文

苹果操作系统版本。10.11.6

Python3版。stable 3.5.2 (bottled), devel 3.6.0rc1, HEAD(通过自制

Pygame版本。homebrew/python/pygame: stable 1.9.2a0, HEAD(pip3和自制的都将得到相同的错误,我将在下面陈述)

Xcode版本Xcode 8.2Build version 8C38。在

终端上我运行:

python3 BattleCity.py

,这(战列城市.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(),但是仍然是相同的错误,所以我想知道上面的两个错误是否相关?在


Tags: theinpy版本终端forversion错误
1条回答
网友
1楼 · 发布于 2024-06-25 23:16:49

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

如果您使用的是自制软件,请在终端上键入以下内容: (在运行下面的代码之前,我通过brew list检查是否安装了下面的任何一个)

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

如果你已经安装了sol峎u混音器,但你的程序仍然不工作(是的,它也不适合我)

尝试:

^{pr2}$

相关问题 更多 >