Portaudio error

I downloaded the latest version of the standalone for OSX and received this error:

Traceback (most recent call last):
  File "/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/sound/backend_pyo.py", line 24, in <module>
    import pyo
  File "/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/pyo/__init__.py", line 27, in <module>
    from .lib import analysis as analysis
  File "/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/pyo/lib/analysis.py", line 32, in <module>
    from ._core import *
  File "/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/pyo/lib/_core.py", line 66, in <module>
    from .._pyo import *
ImportError: dlopen(/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/pyo/_pyo.cpython-38-darwin.so, 0x0002): Library not loaded: @loader_path/libportaudio.2.dylib
  Referenced from: /Applications/PsychoPy.app/Contents/Resources/lib/python3.8/pyo/_pyo.cpython-38-darwin.so
  Reason: tried: '/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/pyo/libportaudio.2.dylib' (no such file), '/usr/local/lib/libportaudio.2.dylib' (no such file), '/usr/lib/libportaudio.2.dylib' (no such file)

I opened up the Pychopy package, and sure-enough, libportaudio.2.dylib was missing from the '/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/pyo/’ folder. So I found a copy of libportaudio.2.dylib and copied it to the pyo folder inside Psychopy.

That got rid of the error, but now I have a new one:

Traceback (most recent call last):
  File "/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/sound/backend_pyo.py", line 15, in <module>
    from .exceptions import DependencyError
ImportError: attempted relative import with no known parent package

I’m stumped.

fyi: 2021 MacBook Pro, macOS 12.3.1

I’ve run into a similar issue, did you ever figure out how to fix it? And also if you remember, where you found a copy of the libportaudio.2.dylib? I’ve only been able to find libportaudio.dylib (without the 2). Thanks!

1 Like

In case it helps, I had a similar issue and resolved it as followed: Library not loaded on MacOS Mojave - #2 by AFG