27
votes

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?

10
gcc can't find the PortAudio header files, did you install the PortAudio dev package (e.g. apt-get install libportaudio-dev for ubuntu)? As a side note, at least in ubuntu pyaudio is already in the repository for both python 2 and 3, and can be installed via apt-get install python(3)-pyaudio. - l4mpi
That works, and I'd accept it as an answer thanks! - Mittenchops

10 Answers

51
votes

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

20
votes

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
18
votes

On Ubuntu:

sudo apt-get install python-pyaudio

or

sudo apt-get install python3-pyaudio
10
votes

Install 2 things,

sudo apt-get install portaudio19-dev python-pyaudio

and then,

pip install pyaudio
6
votes

For Centos7:

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

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

3
votes
  • 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

0
votes

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.

0
votes

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
-2
votes

try this command pip install PyAudio