如何在MacOS上安装pyaudio

问题描述 投票:0回答:1

运行命令:“pip3 install pyaudio”时,出现此错误:

"Collecting pyaudio
Using cached PyAudio-0.2.14.tar.gz (47 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
 ╰─> [18 lines of output]
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.9-x86_64-cpython-38
  creating build/lib.macosx-10.9-x86_64-cpython-38/pyaudio
  copying src/pyaudio/__init__.py -> build/lib.macosx-10.9-x86_64-cpython-38/pyaudio
  running build_ext
  building 'pyaudio._portaudio' extension
  creating build/temp.macosx-10.9-x86_64-cpython-38
  creating build/temp.macosx-10.9-x86_64-cpython-38/src
  creating build/temp.macosx-10.9-x86_64-cpython-38/src/pyaudio
  gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DMACOS=1 -I/usr/local/include -I/usr/include -I/opt/homebrew/include "-I<PATH FROM STEP 3>/include/" -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c src/pyaudio/device_api.c -o build/temp.macosx-10.9-x86_64-cpython-38/src/pyaudio/device_api.o
  src/pyaudio/device_api.c:9:10: fatal error: 'portaudio.h' file not found
  #include "portaudio.h"
           ^~~~~~~~~~~~~
  1 error generated.
  error: command '/usr/bin/gcc' failed with exit code 1
  [end of output]

注意:此错误源自子进程,可能不是 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"

我运行的是 MacOS 14.3.1。 有什么建议吗?

installation pip subprocess pyaudio
1个回答
0
投票

您应该首先通过brew安装portaudio:

brew install portaudio
pip3 install pyaudio
© www.soinside.com 2019 - 2024. All rights reserved.