Asmember
Asmember

Reputation: 21

Installation of PyAudio on Raspberry pi 3 fails with gcc error

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

Upvotes: 2

Views: 6311

Answers (2)

25mhz
25mhz

Reputation: 1102

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.

Upvotes: 5

Julian
Julian

Reputation: 1542

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

Try the same solution:

sudo apt-get install python-pyaudio

Upvotes: 1

Related Questions