2

I'm trying to install PyAudio on my Raspbery Pi 3 using pip install pyaudio but I'm getting the following error:

compilation terminated.
    
error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1

Here are the full logs:

pip install pyaudio

Downloading/unpacking pyaudio

  Downloading PyAudio-0.2.11.tar.gz

  Running setup.py (path:/tmp/pip-build-u0HEK5/pyaudio/setup.py) egg_info for package pyaudio
    
Installing collected packages: pyaudio

  Running setup.py install for pyaudio

building '_portaudio' extension

arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c src/_portaudiomodule.c -o build/temp.linux-armv7l-2.7/src/_portaudiomodule.o
src/_portaudiomodule.c:29:23: fatal error: portaudio.h: No such file or directory

 #include "portaudio.h"
                       ^
compilation terminated.

error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1

Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-u0HEK5/pyaudio/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-g5l7H9-record/install-record.txt --single-version-externally-managed --compile:

running install

running build

running build_py

creating build

creating build/lib.linux-armv7l-2.7

copying src/pyaudio.py -> build/lib.linux-armv7l-2.7

running build_ext

building '_portaudio' extension

creating build/temp.linux-armv7l-2.7

creating build/temp.linux-armv7l-2.7/src

arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c src/_portaudiomodule.c -o build/temp.linux-armv7l-2.7/src/_portaudiomodule.o

src/_portaudiomodule.c:29:23: fatal error: portaudio.h: No such file or directory

 #include "portaudio.h"

                       ^

compilation terminated.

error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
Cleaning up...

Command /usr/bin/python -c "import setuptools,
tokenize;__file__='/tmp/pip-build-u0HEK5/pyaudio/setup.py';exec(compile(getattr(tokenize,
'open', open)(__file__).read().replace('\r\n', '\n'), __file__,
'exec'))" install --record /tmp/pip-g5l7H9-record/install-record.txt
--single-version-externally-managed --compile failed with error code 1 in /tmp/pip-build-u0HEK5/pyaudio 

Storing debug log for failure in /home/pi/.pip/pip.log
Cornelius Roemer
  • 3,772
  • 1
  • 24
  • 55
Asmember
  • 21
  • 1
  • 2

2 Answers2

5

Note: this a Detailed steps for the installation, for faster installation please consider using @Julian's answer.

That is because you dont have proper prerequisites for the "pyaudio", and port audio header files are one of them.

so first install the prerequisites then your installation will succeed. try the below commands first before installing pyaudio.

sudo apt-get update

sudo apt-get install libportaudio0 libportaudio2 libportaudiocpp0 portaudio19-dev

sudo apt-get install python-dev 

after this now install pyaudio installation either from downloaded file or from a git repository

sudo pip install pyaudio

or

sudo apt-get install git

sudo git clone http://people.csail.mit.edu/hubert/git/pyaudio.git

cd pyaudio

sudo python setup.py install 

anything else leave a comment below.

25mhz
  • 1,052
  • 2
  • 10
  • 14
  • 1
    That's a very long-winded way of installing something already in the apt repository. `sudo apt-get install python-pyaudio` does all of that. – Julian Jan 07 '18 at 20:40
  • I know, but expertise of behind the scenes is only gained when its manually done, for that if he understood its because of lack of experience he asked the question. Its clearly visible isnt it ? @julian – 25mhz Jan 07 '18 at 21:26
  • 1
    So gave a lengthy explanation. – 25mhz Jan 07 '18 at 21:26
  • 1
    This worked for me while @Julian's response didn't. Thank you! – Andrew Earl Apr 24 '18 at 16:34
1

This is related to Pyaudio installation error - 'command 'gcc' failed with exit status 1'

Try the same solution:

sudo apt-get install python-pyaudio
Julian
  • 1,522
  • 11
  • 26