portaudio.h: No such file or directory

This should help

$ sudo apt-get install portaudio19-dev python-pyaudio python3-pyaudio

Tested on Ubuntu 18.04, Python 3.7.2, pyaudio 0.2.11

Added 8th of Jan 2021:

On Ubuntu 20.04 you have to use:

$ sudo apt install portaudio19-dev python3-pyaudio

For Windows,
here's what I've been going through...

There're several ways to install PortAudio

  • vcpkg, https://vcpkg.info/port/portaudio

  • winget, https://winget.run/pkg/intxcc/pyaudio

  • Or, manually build from source and install manually

    1. download source, http://files.portaudio.com/download.html
    2. build with cmake, with the matching compiler(msvc/mingw) and arch(x64/x86) to your Python
    3. put "portaudio.h" into python-include directory, e.g. c:\Python38-32\include\
    4. put "portaudio.lib into python-lib directory, e.g. c:\Python38-32\libs

Arrh!
the "min()" macro in pyaudio's soucefile _portaudiomodule.c is troublesome, comment it out manually

  • pip install pyaudio --no-clean
  • find _portaudiomodule.c in the temp directory and manually comment-out the "min()" macro
    e.g. c:\Temp\pip-install-yysb8bme\pyaudio_c92585\src\_portaudiomodule.c
  • pip install from that directory
    e.g. pip install c:\Temp\pip-install-yysb8bme\pyaudio_c92585\

Or,3rd party wheels

  • this answer said:

pip install pipwin
pipwin install pyaudio


For Centos7/RHEL:

yum install portaudio-devel alsa-lib-devel portaudio
pip install pyaudio --user

For MacOS:

brew install portaudio
pip3 install pyaudio