如何在没有子进程退出并带有错误代码的情况下安装 pyAudio,"failed to build wheels"



每次我运行pip安装pyaudio时,我都会收到以下错误

pip3 install pyaudio
Collecting pyaudio
Using cached PyAudio-0.2.12.tar.gz (42 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pyaudio
Building wheel for pyaudio (pyproject.toml) ... error
error: subprocess-exited-with-error

× Building wheel for pyaudio (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [16 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.9-universal2-cpython-310
copying src/pyaudio.py -> build/lib.macosx-10.9-universal2-cpython-310
running build_ext
building '_portaudio' extension
creating build/temp.macosx-10.9-universal2-cpython-310
creating build/temp.macosx-10.9-universal2-cpython-310/src
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -DMACOSX=1 -I/usr/local/include -I/usr/include -I/Library/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c src/_portaudiomodule.c -o build/temp.macosx-10.9-universal2-cpython-310/src/_portaudiomodule.o
src/_portaudiomodule.c:31:10: fatal error: 'portaudio.h' file not found
#include "portaudio.h"
^~~~~~~~~~~~~
1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for pyaudio
Failed to build pyaudio
ERROR: Could not build wheels for pyaudio, which is required to install pyproject.toml-based projects

我尝试了pip安装,重新安装端口音频,但没有任何效果,有什么建议可以解决这个问题吗?

这是在M1 Max上测试过的,所以pyaudio绝对应该支持该平台。

由于您portaudiohomebrew安装,因此执行此操作...

LDFLAGS="-L$(brew --prefix portaudio)/lib" CFLAGS="-I$(brew --prefix portaudio)/include" pip install pyaudio

希望您已经构建并安装了它:

python3 -c "import pyaudio; print(pyaudio.__version__)"
0.2.12

我是M1 mac用户。 对这种方式有压倒性的答案,但对我不起作用。 安装 pyaudio 时,pip 在/usr/local/include 中找不到 portaudio.h

但我发现@wkl的回答对我有用!谢谢。

昨天我用语音助手开始了一个项目,但偶然发现了 PyAudio :((

正如昆腾所说,我尝试了很多不同的东西,但是当我尝试WKL的建议时,一切都到位了!太棒了,谢谢WKL你拯救了我的神经细胞!

取而代之的是:

python3 -c "import pyaudio; print(pyaudio.__version__)"

最好使用这个:

pip show pyaudio

⚠️ 很抱歉在这里发帖,因为我是新用户,无法对他的作品进行评分以使评级生效。

相关内容

  • 没有找到相关文章

最新更新