# Microphone component not working- help

**URL:** <https://discourse.psychopy.org/t/microphone-component-not-working-help/10665>\
**Category:** Builder\
**Created:** [January 22, 2020, 1:19am UTC](https://discourse.psychopy.org/t/microphone-component-not-working-help/10665 "2020-01-22T01:19:51Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hannah96](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/hannah96/32/6725_2.png) [@Hannah96](https://discourse.psychopy.org/u/Hannah96)\
**Post date:** [January 22, 2020, 1:19am UTC](https://discourse.psychopy.org/t/microphone-component-not-working-help/10665/1 "2020-01-22T01:19:51Z")

</div>

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

Hannah

Code:  
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’,)

 ![Screen Shot 2020-01-21 at 7.59.58 PM](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/a/a/aa53b11adcf01c291d4b1b521e103174e1dcd2e3.jpeg)

---

<div class="post-metadata">

**Author:** ![Michael](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/michael/32/16_2.png) [@Michael](https://discourse.psychopy.org/u/Michael)\
**Post date:** [January 22, 2020, 1:36am UTC](https://discourse.psychopy.org/t/microphone-component-not-working-help/10665/2 "2020-01-22T01:36:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jon](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jon/32/22_2.png) [@jon](https://discourse.psychopy.org/u/jon)\
**Post date:** [January 22, 2020, 10:34am UTC](https://discourse.psychopy.org/t/microphone-component-not-working-help/10665/3 "2020-01-22T10:34:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jon](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jon/32/22_2.png) [@jon](https://discourse.psychopy.org/u/jon)\
**Post date:** [January 22, 2020, 10:37am UTC](https://discourse.psychopy.org/t/microphone-component-not-working-help/10665/4 "2020-01-22T10:37:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Hannah96](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/hannah96/32/6725_2.png) [@Hannah96](https://discourse.psychopy.org/u/Hannah96)\
**Post date:** [January 24, 2020, 3:04pm UTC](https://discourse.psychopy.org/t/microphone-component-not-working-help/10665/5 "2020-01-24T15:04:51Z")

</div>

@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?

Thanks,  
Hannah

![Capture](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/9/6/969380082056f9a32181d17c1d6b79256893ab55.png) ![Capture2](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/e/1/e178285040d3dad3bd4a0f8e3f90400fe8e7ce70.png)

 ![Capture3](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/6/d/6d44dd7825f0db14164f2a3d4e768c6b7d10f475.png)  
 ![Capture4](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/c/1/c13bf3c837aef8508e14eb0cdc041a52f21de2af.png)

---

<div class="post-metadata">

**Author:** ![belangeo](https://avatars.discourse-cdn.com/v4/letter/b/dec6dc/32.png) [@belangeo](https://discourse.psychopy.org/u/belangeo)\
**Post date:** [January 29, 2020, 10:37am UTC](https://discourse.psychopy.org/t/microphone-component-not-working-help/10665/6 "2020-01-29T10:37:28Z")

</div>

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:

> <https://github.com/belangeo/cecilia5/blob/master/scripts/builder_OSX.sh#L69>

---

<div class="post-metadata">

**Author:** ![Becca](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/becca/32/34260_2.png) [@Becca](https://discourse.psychopy.org/u/Becca)\
**Post date:** [May 12, 2020, 12:07pm UTC](https://discourse.psychopy.org/t/microphone-component-not-working-help/10665/7 "2020-05-12T12:07:13Z")

</div>

> [@belangeo](#):
>
> libportaudio

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.

Becca ![Screen Shot 2020-05-12 at 13.06.14](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/4/f/4f667a77b8aa05e44958009a2d438e428ee45c1f.png)

---

<div class="post-metadata">

**Author:** ![Marti\_na](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/marti_na/32/8634_2.png) [@Marti\_na](https://discourse.psychopy.org/u/Marti_na)\
**Post date:** [May 23, 2020, 10:47am UTC](https://discourse.psychopy.org/t/microphone-component-not-working-help/10665/8 "2020-05-23T10:47:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Hannah96](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/hannah96/32/6725_2.png) [@Hannah96](https://discourse.psychopy.org/u/Hannah96)\
**Post date:** [May 23, 2020, 1:54pm UTC](https://discourse.psychopy.org/t/microphone-component-not-working-help/10665/9 "2020-05-23T13:54:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Becca](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/becca/32/34260_2.png) [@Becca](https://discourse.psychopy.org/u/Becca)\
**Post date:** [May 23, 2020, 7:49pm UTC](https://discourse.psychopy.org/t/microphone-component-not-working-help/10665/10 "2020-05-23T19:49:24Z")

</div>

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 🙂 (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?

---

<div class="post-metadata">

**Author:** ![pavle](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/pavle/32/8641_2.png) [@pavle](https://discourse.psychopy.org/u/pavle)\
**Post date:** [May 23, 2020, 10:51pm UTC](https://discourse.psychopy.org/t/microphone-component-not-working-help/10665/11 "2020-05-23T22:51:05Z")

</div>

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?

Thanks,  
Renato

---

<div class="post-metadata">

**Author:** ![jon](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jon/32/22_2.png) [@jon](https://discourse.psychopy.org/u/jon)\
**Post date:** [May 25, 2020, 8:25am UTC](https://discourse.psychopy.org/t/microphone-component-not-working-help/10665/12 "2020-05-25T08:25:49Z")

</div>

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. :-/

---

<div class="post-metadata">

**Author:** ![Marti\_na](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/marti_na/32/8634_2.png) [@Marti\_na](https://discourse.psychopy.org/u/Marti_na)\
**Post date:** [May 27, 2020, 7:37am UTC](https://discourse.psychopy.org/t/microphone-component-not-working-help/10665/13 "2020-05-27T07:37:01Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Lmf](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/lmf/32/5718_2.png) [@Lmf](https://discourse.psychopy.org/u/Lmf)\
**Post date:** [July 4, 2020, 5:41pm UTC](https://discourse.psychopy.org/t/microphone-component-not-working-help/10665/14 "2020-07-04T17:41:21Z")

</div>

@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!

---

<div class="post-metadata">

**Author:** ![Eris](https://avatars.discourse-cdn.com/v4/letter/e/c57346/32.png) [@Eris](https://discourse.psychopy.org/u/Eris)\
**Post date:** [July 9, 2020, 6:20pm UTC](https://discourse.psychopy.org/t/microphone-component-not-working-help/10665/15 "2020-07-09T18:20:25Z")

</div>

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

Thanks so much!

---

<div class="post-metadata">

**Author:** ![rendongcai](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/rendongcai/32/31327_2.png) [@rendongcai](https://discourse.psychopy.org/u/rendongcai)\
**Post date:** [October 20, 2021, 7:51am UTC](https://discourse.psychopy.org/t/microphone-component-not-working-help/10665/16 "2021-10-20T07:51:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lir1995](https://avatars.discourse-cdn.com/v4/letter/l/34f0e0/32.png) [@lir1995](https://discourse.psychopy.org/u/lir1995)\
**Post date:** [November 4, 2021, 5:25pm UTC](https://discourse.psychopy.org/t/microphone-component-not-working-help/10665/17 "2021-11-04T17:25:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Becca](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/becca/32/34260_2.png) [@Becca](https://discourse.psychopy.org/u/Becca)\
**Post date:** [November 7, 2021, 6:08pm UTC](https://discourse.psychopy.org/t/microphone-component-not-working-help/10665/18 "2021-11-07T18:08:25Z")

</div>

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?

Thanks,  
Becca

---

<div class="post-metadata">

**Author:** ![lir1995](https://avatars.discourse-cdn.com/v4/letter/l/34f0e0/32.png) [@lir1995](https://discourse.psychopy.org/u/lir1995)\
**Post date:** [November 7, 2021, 6:27pm UTC](https://discourse.psychopy.org/t/microphone-component-not-working-help/10665/19 "2021-11-07T18:27:22Z")

</div>

@Becca Thanks for following up! I created a new post here - [No sound from microphone - #2 by lir1995](https://discourse.psychopy.org/t/no-sound-from-microphone/25790/2) - a few days ago prior to posting this message. Any help would be appreciated, as I am running the most recent release!
