Microphone component not working- help

OS (e.g. Win10): Mojave
PsychoPy version (e.g. 1.84.x): 3.2.4
Standard Standalone? (y/n) If not then what?: yes
What are you trying to achieve?: Get my microphone component to work

What did you try to make it work?: I’ve tried changing my audio drivers and system preferences. I’ve made sure my mic actually hooks to my Mac and that my Mac can read it.

What specifically went wrong when you tried that?:
I added my microphone component to my experiment but when I try to run it, it does not work. I get the error below. When I remove the component the program works perfectly. I am new to Psychopy and this is my first experiment so it could be a silly mistake but I cannot figure it out. Please let me know what I must do to get the microphone component to work.


Generating PsychoPy script…

Running: /Users/hannah/Documents/Graduate School/Lab/Prospectus/Pilot study/PsychoPy/Mathexperiment _lastrun.py
2020-01-21 20:01:46.877 python[2026:87308] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to (null)
Traceback (most recent call last):
File “/Users/hannah/Desktop/PsychoPy3.app/Contents/Resources/lib/python3.6/psychopy/sound/backend_pyo.py”, line 19, in
import pyo
File “pyo/init.pyc”, line 28, in
File “pyo/lib/analysis.pyc”, line 32, in
File “pyo/lib/_core.pyc”, line 58, in
File “pyo/_pyo.pyc”, line 14, in
File “pyo/_pyo.pyc”, line 10, in __load
File “imp.pyc”, line 342, in load_dynamic
ImportError: dlopen(/Users/hannah/Desktop/PsychoPy3.app/Contents/Resources/lib/python3.6/lib-dynload/pyo/_pyo.so, 2): Library not loaded: @loader_path/libportaudio.2.dylib
Referenced from: /Users/hannah/Desktop/PsychoPy3.app/Contents/Resources/lib/python3.6/lib-dynload/pyo/_pyo.so
Reason: image not found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/Users/hannah/Documents/Graduate School/Lab/Prospectus/Pilot study/PsychoPy/Mathexperiment _lastrun.py”, line 18, in
from psychopy import sound, gui, visual, core, data, event, logging, clock, microphone
File “/Users/hannah/Desktop/PsychoPy3.app/Contents/Resources/lib/python3.6/psychopy/microphone.py”, line 45, in
from psychopy.sound import backend_pyo
File “/Users/hannah/Desktop/PsychoPy3.app/Contents/Resources/lib/python3.6/psychopy/sound/backend_pyo.py”, line 23, in
raise exceptions.DependencyError(repr(err))
psychopy.exceptions.DependencyError: ImportError(‘dlopen(/Users/hannah/Desktop/PsychoPy3.app/Contents/Resources/lib/python3.6/lib-dynload/pyo/_pyo.so, 2): Library not loaded: @loader_path/libportaudio.2.dylib\n Referenced from: /Users/hannah/Desktop/PsychoPy3.app/Contents/Resources/lib/python3.6/lib-dynload/pyo/_pyo.so\n Reason: image not found’,)

Hi Hannah,

I’ve deleted the other identical post in another thread - it just creates confusion and duplication of effort.

You seem to have done the right things. Despite setting PTB as the preferred audio library, the error is still coming from the pyo library - I’m not sure if that means that PTB isn’t available or if it doesn’t actually handle microphones. @jon might be the best one to give guidance here.

I’m afraid PTB backaned doesn’t support mic yet. It can do (technically) and should have better timing, but I haven’t written that support at the PsychoPy interface yet.

What I’m puzzled by is why the loading of the pyo lib isn’t working on this machine :-/
I wasn’t aware of any issues with that lib in the recent releases

@Michael @jon
Hi Michael and Jon,
I got the microphone component to run on a windows computer so there must have been an issue with using my mac. I am now having a problem with hearing the sound once I record something. I have the .wav files but when I play them there are no sounds. I made sure my audio was set to my headset but I still can’t hear anything. I also tried changing audio device to ‘Headset Earphone (Logitech USB Headset)’ and ‘Headset Earphone (USB Audio Device)’ but neither of those work. Any idea what the issue might be?


Capture Capture2


Hi @jon, it might be relevant… When I bundle Cecilia5 into an app with py2app, I have to manually change _pyo.so’s external lib paths because py2app puts every dylib in the Frameworks folder. I think you have the same problem here. You can take a look at the Cecilia’s builder script:

1 Like

FYI this does appear to be the problem. In my version of PsychoPy 2020.1.2 on MacOS libportaudio.2 is appears in the folder “Frameworks”. Copying the following list of files to the “lib-dynload/pyo” directory allows me to import pyo without the previous error ("image not found - even when typed to the shell). BUT this does result in a bug where the window doesn’t open, and means that I cannot reopen PsychoPy when I close it and reopen it.

Hoping to take another look at this soon as i am also trying to use the mic component, but posting update here incase helpful.

BeccaScreen Shot 2020-05-12 at 13.06.14

Hi @Hannah96, I was wondering if you were ever able to fix this problem as I’m dealing with the same issue (i.e. pyo image not found error with IOS and empty recordings with Win).

Hi @Marti_na,
I was not able to resolve the issue. I ended up going to a different program. Sorry!

1 Like

Hi @Marti_na , I think the suggestion by @belangeo above is the solution, but it is one that needs implementing on the psychopy source code rather than your local copy :slight_smile: (it is something I was hoping to try and get around to soon as also using the mic on mac!) @jon might be able to advise more if this solution sounds simple to implement?


Hi everybody! I was wondering, since I need to use audio recording only to collect data that is not time-sensitive (latency is fine), is there any other option to make it work in PsychoPy3 ? Maybe using other sound libraries I’ve read about like sounddevice or pygame instead of pyo library?


The plan is to switch to using psychtoolbox lib for this, as we’ve done for audio outputs, which should have superior timing. I just haven’t had time to get there yet. :-/

Thank you @Hannah96, @Becca and @jon for taking the time to reply!

It seems @belangeo solution is not implementable here because we cannot manually change the source (the file is already complied) (which is probably also why @Becca attempt to copy the libraries resulted in PsychoPy not reopening).

Thank you all anyway!

@Becca @jon I am a Mac user encountering the same problem - I shifted all the files as suggested and now the experiment starts up without an error, shows the background of the first routine’s screen but no components, and crashes entirely. I’m not able to esc or proceed and must restart my computer entirely.

Any solutions you’ve found or come back to would be great! Thanks!

@jon I am also encountering the same error with the microphone. Are there any updates on this end?

Thanks so much!


I am having the same issue. I was also wondering any update for this issue?

I am also having the same issue and was wondering if there were any updates? Specifically, I am able to create .wav files but they are empty.

Hi There,

This sounds like possibly a new issue if you are running the most recent release and no error message is produced - please can you start a new thread with details of the problem?


@Becca Thanks for following up! I created a new post here - No sound from microphone - #2 by lir1995 - a few days ago prior to posting this message. Any help would be appreciated, as I am running the most recent release!