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

我们两清 提交于 2020-03-23 02:24:14

问题


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


回答1:


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.




回答2:


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

Try the same solution:

sudo apt-get install python-pyaudio


来源:https://stackoverflow.com/questions/48135955/by-installing-pyaudio-python3-on-my-raspberry-pi-3-noobs-i-get-an-error-how

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!