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

1.9k views Asked by At

OS X ver. 10.11.6;

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

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.

On Terminal I run:

python3 BattleCity.py

,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.

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?

1

There are 1 answers

0
NeoZoom.lua On BEST ANSWER

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

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

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

Try:

brew reinstall sdl_mixer --with-libvorbis