portaudio.h:没有这样的文件或目录

时间:2018-02-08 17:03:45

标签: python speech-recognition google-speech-api

尝试在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/

4 个答案:

答案 0 :(得分:1)

这应该有帮助

$ sudo apt-get install portaudio19-dev python-pyaudio python3-pyaudio

Ubuntu 18.04Python 3.7.2pyaudio 0.2.11上进行了测试

答案 1 :(得分:1)

对于 Windows,
这是我所经历的......

安装 PortAudio 有多种方法

啊!
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