Fixed: ERROR: Could not build wheels for pyaudio, which is required to install pyproject.toml-based projects

Hello, I was trying to install pyaudio on my new Mac device and I came across this error while installing with pip: ERROR: Could not build wheels for pyaudio, which is required to install pyproject.toml-based projects

I somehow figured out the issue and solved it on my own.

I thought it would be worth sharing the solution with you.

I tried running: pip install pyaudio

This is the actual error that I got:

#include "portaudio.h"
               ^~~~~~~~~~~~~
      1 error generated.
      error: command '/usr/bin/clang' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pyaudio
Failed to build pyaudio
ERROR: Could not build wheels for pyaudio, which is required to install pyproject.toml-based projects

ERROR: Could not build wheels for pyaudio, which is required to install pyproject.toml-based projects

How to fix this error:

Just paste the below command and hit enter:

brew install portaudio

Then you can run

pip install pyaudio

This fixed my issue and hopefully, it will fix yours too.

If you are thinking why the error occurred earlier then here’s the reason:

pyaudio package needs files from portaudio, thus you need to install the portaudio first.

This is the output after I fixed the issue:

pip install pyaudio on mac

If you are still facing issues, do let me know in the comment section.

Leave a Reply

Your email address will not be published. Required fields are marked *