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
相关推荐
誉鏐27 分钟前
PyTorch复现线性模型
人工智能·pytorch·python
weixin_435208161 小时前
通过 Markdown 改进 RAG 文档处理
人工智能·python·算法·自然语言处理·面试·nlp·aigc
东方佑2 小时前
利用Python自动化处理PPT样式与结构:从提取到生成
python·自动化·powerpoint
橘猫云计算机设计2 小时前
基于springboot的考研成绩查询系统(源码+lw+部署文档+讲解),源码可白嫖!
java·spring boot·后端·python·考研·django·毕业设计
超级小的大杯柠檬水2 小时前
修改Anaconda中Jupyter Notebook默认工作路径的详细图文教程(Win 11)
ide·python·jupyter
2401_840192272 小时前
如何学习一门计算机技术
开发语言·git·python·devops
巷北夜未央3 小时前
Python每日一题(14)
开发语言·python·算法
大模型真好玩3 小时前
理论+代码一文带你深入浅出MCP:人工智能大模型与外部世界交互的革命性突破
人工智能·python·mcp
呵呵哒( ̄▽ ̄)"3 小时前
线性代数:同解(1)
python·线性代数·机器学习