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
相关推荐
今天头发还在吗1 小时前
【Go】:mac 环境下GoFrame安装开发工具 gf-cli——gf_darwin_arm64
macos·golang·go·gf-cli
小妖6664 小时前
MAC在home下新建文件夹报错“mkdir: test: Operation not supported”
macos
luckys.one4 小时前
第9篇:Freqtrade量化交易之config.json 基础入门与初始化
javascript·数据库·python·mysql·算法·json·区块链
大翻哥哥6 小时前
Python 2025:量化金融与智能交易的新纪元
开发语言·python·金融
zhousenshan7 小时前
Python爬虫常用框架
开发语言·爬虫·python
IMER SIMPLE7 小时前
人工智能-python-深度学习-经典神经网络AlexNet
人工智能·python·深度学习
CodeCraft Studio8 小时前
国产化Word处理组件Spire.DOC教程:使用 Python 将 Markdown 转换为 HTML 的详细教程
python·html·word·markdown·国产化·spire.doc·文档格式转换
专注API从业者8 小时前
Python/Java 代码示例:手把手教程调用 1688 API 获取商品详情实时数据
java·linux·数据库·python
北冥有鱼被烹8 小时前
【问题解决】mac笔记本遇到鼠标无法点击键盘可响应处理办法?(Command+Option+P+R)
macos
java1234_小锋8 小时前
[免费]基于Python的协同过滤电影推荐系统(Django+Vue+sqlite+爬虫)【论文+源码+SQL脚本】
python·django·电影推荐系统·协同过滤