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

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 portaudiobrew link portaudiopip install pyaudio

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