OS (e.g. Win10): MacOS 10.15.6
PsychoPy version (e.g. 1.84.x): 2020.2.4
Standard Standalone? (y/n) y
I have a working psychopy experiment which I wanted to run with pygame as the audio engine. I changed this in Settings–> Audio, saved, exported to runner, and tried to run.
Now, I get this error message in the Stdout window on starting the experiment:
0.4158 WARNING pygame audio lib was requested but not loaded: ModuleNotFoundError("No module named 'pygame'",)
Traceback (most recent call last):
File "PATH/exp_lastrun.py", line 19, in <module>
from psychopy import sound, gui, visual, core, data, event, logging, clock
File "/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/sound/__init__.py", line 102, in <module>
psychopy.exceptions.DependencyError: No sound libs could be loaded. Tried: ['pygame']
Check whether the necessary sound libs are installed
##### Experiment ended. #####
Is there a way to install pygame, or should it be packaged with the download?
It should be yes, however you can also install Pygame manually!
As a habitual Windows user I’ll defer to @jon on this one - I could certainly walk you through installing a package using the Windows command prompt and I believe it’s pretty similar on Mac, but I don’t want to give any advice I can’t test myself.
Yes, the issue here was code signing. Mac really demands signing of apps now and blocks apps that aren’t fully signed and “notarized” which is why there were so many problems getting PsychoPy to run at all on the mac recently.
The version of pygame I had on my mac refused to code-sign because they were using SDL libs that are compiled on old versions of the mac SDK (I think is the reason). I wasn’t able to fix that issue quickly - I believe I need to install a “dev” version of pygame 2.0.0 to get more recent binaries but that will need testing to make sure nothing breaks
Workaround1 : use a different sound engine. Pygame has pretty much the worst timing of all the options. Is there a reason you need it?
Workaround 2: you should be able to get pygame working by installing it to another python3 installation on your system and then pointing PsychoPy preference for additional libs to include that folder
Thanks @jon for all your work to make PsychoPy Mac-friendly, I’m sure it’s not easy but I really appreciate being able to run it!
I had originally posted this because I was trying to see if different sound engines would fix the problem in this thread (still unresolved). But from the looks of it, sound engine is not the problem.
I know Jon is a busy guy, so I don’t want to bother him too much. But could anyone here explain how to do workaround 2 at an idiot proof level? Thanks!
To get pygame on Big Sur I think the steps would be:
- install Python 3.6 from Python.org e.g. Python Release Python 3.6.7 | Python.org
- install pygame for that python install with something like :
/Library/Frameworks/Python.framework/Versions/3.6/Python -m pip install pygame
- Find the path to that package (eg.
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages) and add that to your PsychoPy prefs somethign like this:
Hopefully then import PsychoPy (before import pygame) will now find your pygame installation in that site packages folder