如何在没有子进程退出并出现错误代码“无法构建轮子”的情况下安装 pyAudio

tre*_*era -1 python macos pyaudio

每次运行 pip install pyaudio 时都会出现以下错误

\n
pip3 install pyaudio\nCollecting pyaudio\n  Using cached PyAudio-0.2.12.tar.gz (42 kB)\n  Installing build dependencies ... done\n  Getting requirements to build wheel ... done\n  Preparing metadata (pyproject.toml) ... done\nBuilding wheels for collected packages: pyaudio\n  Building wheel for pyaudio (pyproject.toml) ... error\n  error: subprocess-exited-with-error\n  \n  \xc3\x97 Building wheel for pyaudio (pyproject.toml) did not run successfully.\n  \xe2\x94\x82 exit code: 1\n  \xe2\x95\xb0\xe2\x94\x80> [16 lines of output]\n      running bdist_wheel\n      running build\n      running build_py\n      creating build\n      creating build/lib.macosx-10.9-universal2-cpython-310\n      copying src/pyaudio.py -> build/lib.macosx-10.9-universal2-cpython-310\n      running build_ext\n      building '_portaudio' extension\n      creating build/temp.macosx-10.9-universal2-cpython-310\n      creating build/temp.macosx-10.9-universal2-cpython-310/src\n      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\n      src/_portaudiomodule.c:31:10: fatal error: 'portaudio.h' file not found\n      #include "portaudio.h"\n               ^~~~~~~~~~~~~\n      1 error generated.\n      error: command '/usr/bin/clang' failed with exit code 1\n      [end of output]\n  \n  note: This error originates from a subprocess, and is likely not a problem with pip.\n  ERROR: Failed building wheel for pyaudio\nFailed to build pyaudio\nERROR: Could not build wheels for pyaudio, which is required to install pyproject.toml-based projects\n
Run Code Online (Sandbox Code Playgroud)\n

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

\n

wkl*_*wkl 5

这是在 M1 Max 上进行测试的,因此pyaudio绝对应该支持该平台。

由于您已从portaudio进行安装homebrew,因此请执行以下操作...

LDFLAGS="-L$(brew --prefix portaudio)/lib" CFLAGS="-I$(brew --prefix portaudio)/include" pip install pyaudio
Run Code Online (Sandbox Code Playgroud)

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

python3 -c "import pyaudio; print(pyaudio.__version__)"
0.2.12
Run Code Online (Sandbox Code Playgroud)