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

Mon*_*kar 5 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/
Run Code Online (Sandbox Code Playgroud)

Mos*_*ted 5

这应该有帮助

$ sudo apt-get install portaudio19-dev python-pyaudio python3-pyaudio
Run Code Online (Sandbox Code Playgroud)

在测试了Ubuntu 18.04Python 3.7.2pyaudio 0.2.11

  • 也适用于``Ubuntu 19.10````、``Python 3.8.0````、``pyaudio 0.2.11````。 (2认同)

WMR*_*dan 5

对于 MacOS(英特尔/苹果芯片):

步骤1:

brew install portaudio
Run Code Online (Sandbox Code Playgroud)

第2步:

brew --prefix portaudio  
Run Code Online (Sandbox Code Playgroud)

步骤 3中将需要上述命令提供的输出,该输出类似于以下内容/opt/homebrew/opt/portaudio

步骤3:

在您的主目录中创建 .pydistutils.cfg

sudo nano ~/.pydistutils.cfg
Run Code Online (Sandbox Code Playgroud)

然后将以下内容粘贴到文件中,保存并退出

[build_ext]
include_dirs=<PATH FROM STEP 2>/include/
library_dirs=<PATH FROM STEP 2>/lib/
Run Code Online (Sandbox Code Playgroud)

步骤4:

pip3 install pyaudio
Run Code Online (Sandbox Code Playgroud)


cao*_*nan 5

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

安装 PortAudio 有多种方法

啊!
pyaudio的soucefile中的“min()”宏_portaudiomodule.c比较麻烦,手动注释掉

  • pip install pyaudio --no-clean
  • 在临时目录中找到_portaudiomodule.c并手动注释掉“min()”宏,
    例如c:\Temp\pip-install-yysb8bme\pyaudio_c92585\src\_portaudiomodule.c
  • pip install从该目录
    例如pip install c:\Temp\pip-install-yysb8bme\pyaudio_c92585\

或者,第 3 方轮子

pip install pipwin
pipwin install pyaudio