1

I have been trying to install pyaudio on a Mac M1 Big Sur but was not able to do so and was stuck on the 'portaudio.h' file not found error.

I managed to install it using a different pip command: pip install --global-option='build_ext' --global-option='-I/opt/homebrew/include' --global-option='-L/opt/homebrew/lib' pyaudio.

However, after installing when I try to run a script involving pyaudio, the script throws the following error:

Could not import the PyAudio C module '_portaudio'.
Traceback (most recent call last):
   File "path/test.py", line 14, in <module>
    import pyaudio  
   File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pyaudio.py", line 116, in <module>
    import _portaudio as pa
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/_portaudio.cpython-39-darwin.so, 2): Symbol not found: _PaMacCore_SetupChannelMap
  Referenced from: /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/_portaudio.cpython-39-darwin.so
  Expected in: flat namespace
 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/_portaudio.cpython-39-darwin.so

Can someone help me with this? I have attempted the solution from this question, but the problem persists.

Emre Sevinç
  • 8,211
  • 14
  • 64
  • 105
Mihir Seth
  • 40
  • 8

2 Answers2

1

While troubleshooting the same (including following the steps in the Stackoverflow question you linked) I ran into this error as well. My final solution was:

My homebrew was only installed in /usr/local which is for rosetta-emulated (Intel) code. 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
-1

this worked for me for ARM M1 processor

  1. arch -arm64 /opt/homebrew/bin/brew install portaudio
  2. 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
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 04 '23 at 13:56
  • This looks like a duplicate of the answer by Group2. If you have unique details you want to add, please add them to your answer or suggest an edit of Group2's answer. – Andrew McClement Jul 06 '23 at 15:53