Pyaudio Installation on M1 mac and Python3 Default on M1

I unable to install pyaudio on Mac m1 chip i tried everything to install it homebrew pip3 pipwin portaudio everything but still I'm getting errors.....and I'm unable to make python 3 default on m1 mac...please help me out

MacBook Air 13″, macOS 11.1

Posted on Apr 7, 2021 2:47 AM

Reply
Question marked as Top-ranking reply

Posted on Sep 10, 2021 12:01 AM

Hello @jitender8076,


I solved this issue on my M1 Mac through the following Steps:

  • Firstly, uninstall the PyAudio & portaudio from you systemby the following commands:
brew uninstall portaudio
pip uninstall pyaudio
  • Update your brew :
brew update
  • Upgrade the wheel and setuptools: 
python3 -m pip install --upgrade pip setuptools wheel
  • Then, install the latest version of portaudio:
brew install portaudio --HEAD
  • Install PyAudio: 
python3 -m pip install pyaudio --global-option="build_ext" --global-option="-I/opt/homebrew/include" --global-option="-L/opt/homebrew/lib"


For Miniforge/ Anaconda environment, install the pyaudio in side the environment i.e:

conda activate myEnvName

python3 -m pip install pyaudio --global-option="build_ext" --global-option="-I/opt/homebrew/include" --global-option="-L/opt/homebrew/lib"



And you are good to go!!!

Similar questions

13 replies
Question marked as Top-ranking reply

Sep 10, 2021 12:01 AM in response to jitender8076

Hello @jitender8076,


I solved this issue on my M1 Mac through the following Steps:

  • Firstly, uninstall the PyAudio & portaudio from you systemby the following commands:
brew uninstall portaudio
pip uninstall pyaudio
  • Update your brew :
brew update
  • Upgrade the wheel and setuptools: 
python3 -m pip install --upgrade pip setuptools wheel
  • Then, install the latest version of portaudio:
brew install portaudio --HEAD
  • Install PyAudio: 
python3 -m pip install pyaudio --global-option="build_ext" --global-option="-I/opt/homebrew/include" --global-option="-L/opt/homebrew/lib"


For Miniforge/ Anaconda environment, install the pyaudio in side the environment i.e:

conda activate myEnvName

python3 -m pip install pyaudio --global-option="build_ext" --global-option="-I/opt/homebrew/include" --global-option="-L/opt/homebrew/lib"



And you are good to go!!!

Apr 7, 2021 5:44 AM in response to jitender8076

Start with modifying the PATH line in. your Zsh shell dot file (~/.zshrc):


export PATH="/usr/local/bin:${PATH}



and then from the Terminal, run the following to make that PATH current:


source ~/.zshrc


Next, you install Python 3.9.4 (universal) directly from Python.org (not using brew) — which is a normal macOS package installer. It will create a Python 3.9 folder in your /Applications folder, deposit python3, idle3, etc in /usr/local/bin as links back to:


/Library/Frameworks/Python.framework/Versions/3.9/bin


and though the Python 3.9.4 installer updates your PATH statement for Bash, it still does not do so for the Zsh shell, so back to your ~/.zshrc dot file for one last change:


export PATH="/Library/Frameworks/Python.framework/Versions/3.9/bin:${PATH}"


and


source ~/.zshrc


If you have installed Xcode, or the command-line tools for Xcode 12.4, these place a Python v3.8.2 into /usr/bin, and if you do not make the preceding PATH adjustments, it is that older Python3 that you get by default, and one that won't let you install modules into it.


The last PyAudio module that I see was last updated in 2017 and very likely not compatible with Python 3.9.4.


One way to avoid polluting the main Python 3.9.4 package area is to create a virtual environment that you install packages into as I have done for pyobjc, pyobjc-core, and Qt 5.15.

Oct 5, 2021 1:53 PM in response to jitender8076

First comment 'brew install portaudio' in a virtual environment then 'pip install pyaudio' or 'pip3 install pyaudio' if these comments don't work try this comment in a virtual enviorenment if you directly paste the comment in terminal maybe doesn`t run 'pip install --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' 


Apr 27, 2021 7:55 AM in response to KunalBhayana

KunalBhayana wrote:

Even I am a longtime Windows user I am regretting this purchase so much.

The whole problem here is that these are unsupported, open-source projects that you can't purchase for any price. The idea is that you purchase an M1 Mac so that you can fix pyaudio, homebrew, pip3, pipwin, portaudio, and Python 3 so that they will work on the M1 for other people. Large corporations like Google, Amazon, and Facebook would really appreciate your work so that they can more easily port their internal code to less expensive ARM-based system. You weren't expecting them to do the work themselves, were you?

Apr 27, 2021 8:10 AM in response to KunalBhayana

KunalBhayana wrote:

I was expecting everything to be ready since it's almost 6 months now.

Actually it has been almost 11 months since Apple Silicon computers have first been available to developers. Apple is only responsible for its own software, which works fine. If you have 3rd party software that isn't working, you will have to contact the developers and let them know.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Pyaudio Installation on M1 mac and Python3 Default on M1

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.