Pygame: pygame.error: 无法打开文件 .ogg [英] Pygame: pygame.error: Unable to open file .ogg

查看:257
本文介绍了Pygame: pygame.error: 无法打开文件 .ogg的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OS X 版本.10.11.6;

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

Python3 ver. stable 3.5.2 (bottled), devel 3.6.0rc1, HEAD(through Homebrew);

Pygame 版本.homebrew/python/pygame: stable 1.9.2a0, HEAD(pip3Homebrew 都会遇到同样的错误,我将在下面说明);

Pygame ver. homebrew/python/pygame: stable 1.9.2a0, HEAD(Both pip3 and Homebrew will got the same error I will state below);

Xcode ver.Xcode 8.2 Build version 8C38.

Xcode ver.Xcode 8.2 Build version 8C38.

终端我运行:

python3 BattleCity.py

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

,which(BattleCity.py) is a game-source-code, and pygame module is imported in it.

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

The following is the result from Terminal: (For readability I've rearranged the indentation and add/remove some non-visible characters)

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'

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

I have searched through some related questions but their solutions don't work.

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

In the file I have used pygame.init(), but still the same error so I wonder whether or not the two errors above are related?

推荐答案

来自 Reddit 上的帖子 我发现该解决方案非常适合播放 .ogg 音乐文件.

From a post on Reddit I found the solution just perfectly works for playing .ogg music-file.

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

If you're using Homebrew, type the following on Terminal: (before I run the following code, I check whether I have installed any one below by brew list)

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

如果你已经安装了 sol_mixer,但你的程序仍然无法运行(是的,它也不适合我),

If you have installed sol_mixer, and your program still don't work(Yes, it also didn't for me),

试试:

brew reinstall sdl_mixer --with-libvorbis

这篇关于Pygame: pygame.error: 无法打开文件 .ogg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆