简体   繁体   中英

by installing PyAudio (Python3) on my Raspberry pi 3 (noobs) I get an error, how could i fix this?

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

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.

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

Try the same solution:

sudo apt-get install python-pyaudio

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM