Trying to install pyaudio with instructions per here:

$ git clone http://people.csail.mit.edu/hubert/git/pyaudio.git
$ cd pyaudio
$ sudo python setup.py install
running install
running build
running build_py
running build_ext
building '_portaudio' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c src/_portaudiomodule.c -o build/temp.linux-x86_64-2.7/src/_portaudiomodule.o
In file included from /usr/include/python2.7/Python.h:8:0,
                 from src/_portaudiomodule.c:28:
/usr/include/python2.7/pyconfig.h:1161:0: warning: "_POSIX_C_SOURCE" redefined [enabled by default]
/usr/include/features.h:215:0: note: this is the location of the previous definition
src/_portaudiomodule.c:29:23: fatal error: portaudio.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1

What’s going wrong in my installation?

Sorry about the inappropriate answer last time, I will post the solution of the question. It might be helpful for Ubuntu distributions.

  1. First we need to install portaudio modules: sudo apt-get install libasound-dev

  2. Download the portaudio archive from: http://files.portaudio.com/download.html

  3. Unzip the archive: tar -zxvf [portaudio.tgz]

  4. Enter the directory, then run: ./configure && make

  5. Install: sudo make install

  6. And finally: sudo pip install pyaudio

  7. Check the version of pyaudio, it should be 0.2.9

This worked for me:

sudo apt-get install libasound-dev portaudio19-dev libportaudio2 libportaudiocpp0
sudo apt-get install ffmpeg libav-tools
sudo pip install pyaudio

On Ubuntu:

sudo apt-get install python-pyaudio

or

sudo apt-get install python3-pyaudio

Install 2 things,

sudo apt-get install portaudio19-dev python-pyaudio

and then,

pip install pyaudio

For Centos7:

sudo yum install -y portaudio-devel
sudo pip install pyaudio

For Windows :

Install using pip:

 python -m pip install pyaudio

if pip is not already bundled with your installation of Python, get it here.

For Mac OS X :

Use Homebrew to install the prerequisite portaudio library, then install PyAudio using pip:

 brew install portaudio
 pip install pyaudio

pip will download the PyAudio source and build it for your version of Python.

For Debian/Ubuntu :

Use the package manager to install PyAudio:

 sudo apt-get install python-pyaudio python3-pyaudio

If the latest version of PyAudio is not available, install it using pip:

pip install pyaudio

For better isolation from system packages, consider installing PyAudio in a virtual environment

PyAudio Source :

Source is available for download at the Python Package Index (PyPI): here!

Or clone the git repository:

git clone https://people.csail.mit.edu/hubert/git/pyaudio.git

credits: PyAudio and GitHub:Speech_Recognition

  • First we need to install portaudio modules: sudo apt-get install
    libasound-dev

  • Download the portaudio archive from:
    http://portaudio.com/download.html

  • Unzip the archive: tar -zxvf [portaudio.tgz]

  • Enter the directory, then run: ./configure && make

  • Install: sudo make install

  • And Then: sudo pip install pyaudio

  • Update & Upgrade the system to fix all broken libraries

  • sudo apt update && sudo apt upgrade

sudo apt-get install libasound-dev portaudio19-dev libportaudio2 libportaudiocpp0
sudo apt-get install ffmpeg# libav-tools
sudo pip install pyaudio

as sayantan ghosh told (in my case, it’s error with libav-tools) and

sudo apt-get install python3-pyaudio

as Aaron told, then pip install pyaudio

these steps works for me, Im in ubuntu 20.04

I am using kali linux 2.0, do as follows:

apt-get install portaudio19-dev python-pyaudio

then:

pip install pyaudio

this worked for me.

Download PyAudio from the link below:
https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio
Then, install this file using the command:

pip install (complete filepath)

Example:

pip install C:\Users\(Username)\Downloads\PyAudio-0.2.11-cp39-cp39-win_amd64.whl

Disclaimer – For Linux
terminal command

  1. Run pip install wheel
  2. Download this https://github.com/Uberi/speech_recognition
    Inside above-mentioned folder
  3. Run pip install ./third-party/WHEEL_FILENAME
    Here Choose your WHEEL from https://github.com/Uberi/speech_recognition/tree/master/third-party

mine was (Linux) - PyAudio-0.2.11.tar.gz

Then Finally Run:
pip install ./third-party/PyAudio-0.2.11.tar.gz (replace pip with pip3 if using Python 3)

On Manjaro(Arch Linux) sudo pacman -S python-pyaudio

I came across this question while getting pyaudio working in an alpine linux container (python:3.9-alpine).

There were some additional packages to install in this case. I’ll post what I had to do in case it’s useful for someone.

apk add --no-cache py3-pyaudio portaudio-dev gcc musl-dev
pip install pyaudio

The pyaudio pip install needs gcc and also the dev files included in musl-dev package.

I could resolved PyAudio error after a long search

Hope this can help someone.

First you find the python version using : python --version (check both Pycharm and JupyterLab as I had 3.7.6 and 3.10.4 different version and move to correct directory – I pasted the same version whl file in same directory “may be there is another way of doing it – suggestions welcome” )

Once this file is placed in the same directory – “PyAudio-0.2.11-cp37-cp37m-win_amd64.whl” you can use pip install PyAudio-0.2.11-cp37-cp37m-win_amd64.whl directly

Other findings :

In case the version and file not matching you will get this error

ERROR: PyAudio-0.2.11-cp310-cp310-win32.whl is not a supported wheel
on this platform.

simple “pip install pyaudio” will not work (As read on internet its not working beyond 3.6)

try this command pip install PyAudio