尝试在ubuntu 16.04中使用pip3安装pyaudio时出现以下错误:
Collecting pyaudio
Downloading PyAudio-0.2.11.tar.gz
Installing collected packages: pyaudio
Running setup.py install for pyaudio ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-mxgvewdb/pyaudio/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-v55chjee-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.5
copying src/pyaudio.py -> build/lib.linux-x86_64-3.5
running build_ext
building '_portaudio' extension
creating build/temp.linux-x86_64-3.5
creating build/temp.linux-x86_64-3.5/src
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c src/_portaudiomodule.c -o build/temp.linux-x86_64-3.5/src/_portaudiomodule.o
src/_portaudiomodule.c:29:23: fatal error: portaudio.h: No such file or directory
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-mxgvewdb/pyaudio/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-v55chjee-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-mxgvewdb/pyaudio/
答案 0 :(得分:1)
这应该有帮助
$ sudo apt-get install portaudio19-dev python-pyaudio python3-pyaudio
在Ubuntu 18.04
,Python 3.7.2
,pyaudio 0.2.11
上进行了测试
答案 1 :(得分:1)
对于 Windows,
这是我所经历的......
安装 PortAudio 有多种方法
或者,从源代码手动构建并手动安装
/
”放入python-include目录,例如portaudio.h
c:\Python38-32\include\
”放入python-lib目录,例如portaudio.lib
啊!
pyaudio的soucefile c:\Python38-32\libs
中的“min()”宏比较麻烦,手动注释掉
_portaudiomodule.c
pip install pyaudio --no-clean
并手动注释掉“min()”宏_portaudiomodule.c
c:\Temp\pip-install-yysb8bme\pyaudio_c92585\src\_portaudiomodule.c
来自该目录pip install
或者,第三者轮子
pip install c:\Temp\pip-install-yysb8bme\pyaudio_c92585\
pip install pipwin
答案 2 :(得分:0)
对于Centos7 / RHEL:
yum install portaudio-devel alsa-lib-devel portaudio
pip install pyaudio --user
答案 3 :(得分:0)
对于 MacOS:
brew install portaudio
pip3 install pyaudio