| Reference | Downloads | Github

Experiment freezes (unresponsive) when using sound.Sound



For some very strange reason, my experiment won’t start (instantly freezes on black screen and goes to ‘not responding’) when I include the following bit of code. The line merely loads in a .wav file and assigns it to a variable. As soon as I comment it out, the script works perfectly fine.

warning_beep = sound.Sound("C:\Users\Eyelink User\Desktop\ocarina.wav")

I’m stumped by this, I’ve never had this problem before and I have no idea how to fix it since it’s a very simple statement. I’m importing sound like this:

from psychopy import visual, core, gui, event, sound

Does anyone have any ideas as to why this line causes my script to go unresponsive? I’m using the latest psychopy.

Update: I tried the same code at home on Psychopy version 1.83.01, and it worked with without any issues. I then installed the newest Psychopy version, and the code does run but I also get a console audio error message (below).

portaudio error in Pa_AbortStream: Unanticipated host error
Exception TypeError: “‘NoneType’ object is not callable” in <bound method Server.del of <pyolib.server.Server object at 0x149EA1B0>> ignored

When I remove the line ‘`warning_beep = sound.Sound(“C:\Users\Eyelink User\Desktop\ocarina.,wav”)’, I no longer get the error message. Does the newest version have some audio issues?



What settings do you have for your sound libraryin PsychoPy preferences?
Does that portaudio error have more lines that you aren’t showing us here?


There are no other error messages other than the ones in my original post. At home, my settings are:

Audio library: [‘pygame’,‘pyo’]
Audio driver: [‘Primary Sound’,‘ASIO’,‘Audigy’]
flac audio compression: empty

On the lab pc the code won’t run at all due to the inclusion of ‘warning_beep = sound.Sound(“C:\Users\Eyelink User\Desktop\ocarina.wav”)’. I will go down and investigate tomorrow.

Happy to roll-back my psychopy of course, but just thought I would mention so you knew.

Update: Apologies, I ran it again and noticed this:

WARNING pygame audio lib was requested but not loaded: No module named pygame


Is this the standalone version of PsychoPy? It should ship with a working copy of PyGame…


For some reason PyGame isn’t being installed with the standalone. However, it can be downloaded here: for the windows installer just change the installation folder to where you have PsychoPy installed and it will do the rest of the work for you.

I can confirm that changing from pyo to pygame resolves these weird problems of experiments crashing, freezing, sound not playing, etc. No idea what’s made pyo unhappy.


On OSX pygame is no longer included because the mac standalone versoin is now 64bit and I can’t find a 64bit version of pygame. It should still be included in windows though (maybe it was missed out at one point?)

With pyo it’s also hard to know but we’ve had lots of problems with that library and I’m keen to ditch it (pyo is the new pygame - a pain in my side). Hopefully the new sounddevice backend will fix the woes the way that moviepy did for movies


Hi All,

I have been having this same problem. However I need to use Pyo because Pygame doesn’t seem to let me play my sound below a certain level (think this is something I should report in another thread but any feedback would be great!). the error I get is:

“portaudio error in Pa_AbortStream: Unanticipated host error”

any ideas how to fix this would be great - my settings are the same as those reported by Steve


What version of PsychoPy do you have installed?
Could you try sounddevice instead of either pyo or pygame? i.e. set your sound lib to be:


If that raises other probs then let us know but that’s the sound lib I’m most interested in fixing for the future