Search code examples
pythonpyaudioportaudio

PyAudio OSError: [Errno -9986] Internal PortAudio error


I'm trying to run PyAudio on OSX on a MacBook Air but I keep getting the error:

||PaMacCore (AUHAL)|| Error on line 1316: err='-66748', msg=Unknown Error
Traceback (most recent call last):
  File "main.py", line 15, in <module>
    stream = p.open(format=p.get_format_from_width(wf.getsampwidth()),
  File "/Users/carlbengtsson/Library/Mobile Documents/com~apple~CloudDocs/stickerapp-ml/sound-detection/venv/lib/python3.8/site-packages/pyaudio.py", line 750, in open
    stream = Stream(self, *args, **kwargs)
  File "/Users/carlbengtsson/Library/Mobile Documents/com~apple~CloudDocs/sound-detection/venv/lib/python3.8/site-packages/pyaudio.py", line 441, in __init__
    self._stream = pa.open(**arguments)
OSError: [Errno -9986] Internal PortAudio error

I'm running Python 3.8.2 and have installed PortAudio using brew. Anyone having had this issue before, having any ideas on where to even start debugging this or alternatives for sound recognition? Thanks


Solution

  • I started getting this error as well after upgrading to Big Sur.

    There seems to be an issue with compiling portaudio against macOS SDK 11. Downgrading XCode to 12.1 (which uses macOS SDK 10.5) on Big Sur has reportedly fixed the issue which is currently being tracked here: https://github.com/PortAudio/portaudio/issues/218#issuecomment-731310548.

    Alternatively, now reinstalling from --HEAD seems to work for me.

    brew uninstall portaudio
    brew install portaudio --HEAD