when installing pyaudio, pip cannot find portaudio.h in /usr/local/include

Since pyAudio has portAudio as a dependency, you first have to install portaudio.

brew install portaudio

Then try: pip install pyAudio. If the problem persists after installing portAudio, you can specify the directory path where the compiler will be able to find the source programs (e.g: portaudio.h). Since the headers should be in the /usr/local/include directory:

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

On Ubuntu builds:

sudo apt-get install python-pyaudio

For Python3:

sudo apt-get install python3-pyaudio

You have to install portaudio first then link that file. Only then you can find that header file (i.e, portaudio.h). To install portaudio in mac by using HomeBrew program use following commands.

brew install portaudio
brew link portaudio
pip install pyaudio

sudo is not needed if you're admin. We should refrain using sudo as it messes up lots of permissions.


First, you can use Homebrew to install portaudio.

brew install portaudio

Then try to find the portaudio path:

sudo find / -name "portaudio.h"

In my case it is at /usr/local/Cellar/portaudio/19.6.0/include .

Run the command below to install pyaudio

pip install --global-option='build_ext' --global-option='-I/usr/local/Cellar/portaudio/19.6.0/include' --global-option='-L/usr/local/Cellar/portaudio/19.6.0/lib' pyaudio


On Raspbian:

sudo apt-get install python-pyaudio