mac m1上pip install pyaudio异常

ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (pyaudio)

复制代码
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-11.1-arm64-cpython-311
      creating build/lib.macosx-11.1-arm64-cpython-311/pyaudio
      copying src/pyaudio/__init__.py -> build/lib.macosx-11.1-arm64-cpython-311/pyaudio
      running build_ext
      building 'pyaudio._portaudio' extension
      creating build/temp.macosx-11.1-arm64-cpython-311
      creating build/temp.macosx-11.1-arm64-cpython-311/src
      creating build/temp.macosx-11.1-arm64-cpython-311/src/pyaudio
      clang -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /opt/anaconda3/envs/MoneyPrinterPlus/include -arch arm64 -fPIC -O2 -isystem /opt/anaconda3/envs/MoneyPrinterPlus/include -arch arm64 -DMACOS=1 -I/usr/local/include -I/usr/include -I/opt/homebrew/include -I/opt/anaconda3/envs/MoneyPrinterPlus/include/python3.11 -c src/pyaudio/device_api.c -o build/temp.macosx-11.1-arm64-cpython-311/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/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: ERROR: Failed to build installable wheels for some pyproject.toml based projects (pyaudio)

解决方式

pyaudio 的安装问题由于缺少底层的音频库导致的。在 Mac 上,安装 portaudio 库,然后再安装 pyaudio。

安装 portaudio:可以使用 Homebrew 进行安装,打开终端,输入以下命令:

复制代码
brew install portaudio

之后在安装 pyaudio: Python 环境中,使用命令安装 pyaudio:

复制代码
pip install pyaudio
相关推荐
Fine姐5 分钟前
传感器WSNs TheDataLinkLayer——X-MAC
macos
276695829217 分钟前
tiktok 弹幕 逆向分析
java·python·tiktok·tiktok弹幕·tiktok弹幕逆向分析·a-bogus·x-gnarly
cylat22 分钟前
Day59 经典时序预测模型3
人工智能·python·深度学习·神经网络
嘉恩督27 分钟前
视频人脸处理——人脸面部动作提取
python·音视频
WJ.Polar28 分钟前
Python数据容器-集合set
开发语言·python
smppbzyc1 小时前
2025年亚太杯(中文赛项)数学建模B题【疾病的预测与大数据分析】原创论文讲解(含完整python代码)
python·数学建模·数据分析·数学建模竞赛·亚太杯数学建模·亚太杯
xiaocainiao8811 小时前
Python 实战:构建可扩展的命令行插件引擎
开发语言·python
运器1232 小时前
【一起来学AI大模型】PyTorch DataLoader 实战指南
大数据·人工智能·pytorch·python·深度学习·ai·ai编程
音元系统2 小时前
Copilot 在 VS Code 中的免费替代方案
python·github·copilot
超龄超能程序猿2 小时前
(5)机器学习小白入门 YOLOv:数据需求与图像不足应对策略
人工智能·python·机器学习·numpy·pandas·scipy