Title: Pygame Mixer unable to be used
Tags: python,macos,pygame

Question: I was trying to use pygame.mixer to generate sine wave audio, however, running the following code:
import pygame
pygame.init()
pygame.mixer.init()

gives me the following error:
RuntimeWarning: use mixer: dlopen(/Users/kids/PycharmProjects/PySynth/venv/lib/python3.9/site-packages/pygame/mixer.cpython-39-darwin.so, 2): Library not loaded: @loader_path/libmp3lame.0.dylib
  Referenced from: /Users/kids/PycharmProjects/PySynth/venv/lib/python3.9/site-packages/pygame/.dylibs/libsndfile.1.0.34.dylib
  Reason: no suitable image found.  Did find:
    /Users/kids/PycharmProjects/PySynth/venv/lib/python3.9/site-packages/pygame/.dylibs/libmp3lame.0.dylib: cannot load 'libmp3lame.0.dylib' (load command 0x80000034 is unknown)
    /Users/kids/PycharmProjects/PySynth/venv/lib/python3.9/site-packages/pygame/.dylibs/libmp3lame.0.dylib: cannot load 'libmp3lame.0.dylib' (load command 0x80000034 is unknown)
(ImportError: dlopen(/Users/kids/PycharmProjects/PySynth/venv/lib/python3.9/site-packages/pygame/mixer.cpython-39-darwin.so, 2): Library not loaded: @loader_path/libmp3lame.0.dylib
  Referenced from: /Users/kids/PycharmProjects/PySynth/venv/lib/python3.9/site-packages/pygame/.dylibs/libsndfile.1.0.34.dylib
  Reason: no suitable image found.  Did find:
    /Users/kids/PycharmProjects/PySynth/venv/lib/python3.9/site-packages/pygame/.dylibs/libmp3lame.0.dylib: cannot load 'libmp3lame.0.dylib' (load command 0x80000034 is unknown)
    /Users/kids/PycharmProjects/PySynth/venv/lib/python3.9/site-packages/pygame/.dylibs/libmp3lame.0.dylib: cannot load 'libmp3lame.0.dylib' (load command 0x80000034 is unknown))
  pygame.mixer.get_sdl_mixer_version()
Traceback (most recent call last):
  File "/Users/kids/PycharmProjects/PySynth/main.py", line 11, in <module>
    pygame.mixer.get_sdl_mixer_version()
  File "/Users/kids/PycharmProjects/PySynth/venv/lib/python3.9/site-packages/pygame/__init__.py", line 70, in __getattr__
    raise NotImplementedError(missing_msg)
NotImplementedError: mixer module not available (ImportError: dlopen(/Users/kids/PycharmProjects/PySynth/venv/lib/python3.9/site-packages/pygame/mixer.cpython-39-darwin.so, 2): Library not loaded: @loader_path/libmp3lame.0.dylib
  Referenced from: /Users/kids/PycharmProjects/PySynth/venv/lib/python3.9/site-packages/pygame/.dylibs/libsndfile.1.0.34.dylib
  Reason: no suitable image found.  Did find:
    /Users/kids/PycharmProjects/PySynth/venv/lib/python3.9/site-packages/pygame/.dylibs/libmp3lame.0.dylib: cannot load 'libmp3lame.0.dylib' (load command 0x80000034 is unknown)
    /Users/kids/PycharmProjects/PySynth/venv/lib/python3.9/site-packages/pygame/.dylibs/libmp3lame.0.dylib: cannot load 'libmp3lame.0.dylib' (load command 0x80000034 is unknown))

In my venv, I checked to see if libmp3lame.0.dylib existed, which it did. I suspected that it could be a problem with my pygame installation, so I reinstalled the libary. No luck. For reference, I am using:

MacOS 10.14 (Mojave)
Python 3.9.6
Pygame 2.4.0
Venv
Pycharm

Answer: This is a bug in pygame buildconfig.
Fortunately it is fixed in pygame-ce (pygame community edition), the modern community fork of pygame.
Pygame-ce is totally backwards compatible with pygame, and has some additional features (and this bug is fixed). You can even still import as pygame.
Try pip uninstall pygame and then pip install pygame-ce --pre (The pre flag is necessary because the bug fix is only in a dev release right now)