2

I have been trying to install PyAudio for a project. I am working on a Mac with the M1 Chip, on OS 11.0.1.

Every time I run pip3 install pyaudio I get the same error:

    #include "portaudio.h"
             ^~~~~~~~~~~~~
    1 error generated.
    error: command 'clang' failed with exit status 1

I have installed portaudio through brew install portaudio and have x-code command line tools but it still doesn't work. I have also tried putting sudo in front of it but no luck.

Any help is appreciated!

Here's an image of the error: Error

Anshul S.
  • 21
  • 7

1 Answers1

6

The PortAudio header file can't be located.

Try running brew link before installing PyAudio:

brew install portaudio
brew link portaudio
pip3 install pyaudio

If this does not work then locate the file, sudo find / -name "portaudio.h", and supply the path as a build_ext option through the pip3 install command. In my case the path returned is /usr/local/include/portaudio.h. Hence, the command is as follows:

pip3 install --global-option='build_ext' --global-option='-I/usr/local/include' --global-option='-L/usr/local/lib' pyaudio

These possible solutions are all described in the related question: when installing pyaudio, pip cannot find portaudio.h in /usr/local/include

fwestberg
  • 76
  • 4