Having trouble installing PyAudio for Python3 on Mint

user3047641 picture user3047641 · Oct 1, 2015 · Viewed 11.1k times · Source

I was following the instructions here and I'm having trouble getting the installation to work. Basically, the first part works fine. I downloaded portaudio, followed the instructions, and it all seemed to work.

However, when I triedpython3 setup.py install, I got an error. The error came from the /src/_portaudiomodule.c file, and it said that "The file Python.h could not be found". I don't really understand what's going on because there was no Python.h file when I extracted the PyAudio archive. I don't know where the Python.h file was supposed to come from.

I'm kind of a noob to unix systems so I could have easily made a mistake somewhere. I've been trying to solve this for hours and I've had no luck so far. Thanks in advance for your help!

Answer

Tomas Ruiz picture Tomas Ruiz · Sep 23, 2017

To install the latest version of pyaudio using conda:

source activate -your environment name-

pip install pyaudio

You may run into the following error when installing from pip:

src/_portaudiomodule.c:29:23: fatal error: portaudio.h: No such file or directory
 #include "portaudio.h" 
 compilation terminated.
 error: command 'gcc' failed with exit status 1

That is because you don't have the PortAudio development package installed. Install it with:

sudo apt-get install portaudio19-dev