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

新手上路,请多包涵

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

原文由 Monojit Sarkar 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 1.3k
2 个回答

这应该有帮助

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

测试于 Ubuntu 18.04Python 3.7.2pyaudio 0.2.11

2021 年 1 月 8 日添加:

在 Ubuntu 20.04 上你必须使用:

 $ sudo apt install portaudio19-dev python3-pyaudio

原文由 Most Wanted 发布,翻译遵循 CC BY-SA 4.0 许可协议

对于 Windows,

这就是我一直在经历的……

有几种安装 PortAudio 的方法

  • vcpkg, https: //vcpkg.info/port/portaudio

  • 小翼, https: //winget.run/pkg/intxcc/pyaudio

  • 或者,从源代码手动构建并手动安装

    1. 下载源,http: //files.portaudio.com/download.html
    2. 使用 cmake 构建,使用与 Python 匹配的 编译器(msvc/mingw)arch(x64/x86)
    3. 将“ portaudio.h ”放入python-include目录,例如 c:\Python38-32\include\
    4. 将“ portaudio.lib 放入python-lib目录,例如 c:\Python38-32\libs

啊!

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

原文由 caoanan 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题