0

I am trying in get pyaudio working on my Mac mini M1

pi@pi-mini ~ % python3 Python 3.9.5 (default, May 3 2021, 19:12:05) [Clang 12.0.5 (clang-1205.0.22.9)] on darwin Type "help", "copyright", "credits" or "license" for more information.

import pyaudio Could not import the PyAudio C module '_portaudio'. Traceback (most recent call last): File "", line 1, in File "/opt/homebrew/lib/python3.9/site-packages/pyaudio.py", line 116, in import _portaudio as pa ImportError: dlopen(/opt/homebrew/lib/python3.9/site-packages/_portaudio.cpython-39-darwin.so, 2): no suitable image found. Did find: /opt/homebrew/lib/python3.9/site-packages/_portaudio.cpython-39-darwin.so: mach-o, but wrong architecture /opt/homebrew/lib/python3.9/site-packages/_portaudio.cpython-39-darwin.so: mach-o, but wrong architecture

any idea what I need to do to fix this?

1 Answers1

0

I was running into the same and finally figured it out.

My homebrew was only installed in /usr/local which is for rosetta-emulated (Intel) code, hence the architecture mismatch. See more information in this Stackoverflow question/answer.

Once I had the correct homebrew installation for ARM64 under /opt/homebrew I removed my previous portaudio installation did the following:

  • $arch -arm64 /opt/homebrew/bin/brew install portaudio
  • $pip3 install --no-cache-dir --global-option='build_ext' --global-option='-I/opt/homebrew/Cellar/portaudio/19.7.0/include' --global-option='-L/opt/homebrew/Cellar/portaudio/19.7.0/lib' pyaudio (More details in this Stackoverflow question/answer) Make sure this path aligns with your arch arm64 portaudio installation.
Group2
  • 13
  • 5