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
相关推荐
喜欢猪猪15 分钟前
Java技术专家视角解读:SQL优化与批处理在大数据处理中的应用及原理
android·python·adb
海绵波波10717 分钟前
flask后端开发(1):第一个Flask项目
后端·python·flask
林的快手22 分钟前
209.长度最小的子数组
java·数据结构·数据库·python·算法·leetcode
从以前37 分钟前
准备考试:解决大学入学考试问题
数据结构·python·算法
Ven%1 小时前
如何修改pip全局缓存位置和全局安装包存放路径
人工智能·python·深度学习·缓存·自然语言处理·pip
枫欢1 小时前
将现有环境192.168.1.100中的svn迁移至新服务器192.168.1.4;
服务器·python·svn
测试杂货铺1 小时前
UI自动化测试实战实例
自动化测试·软件测试·python·selenium·测试工具·测试用例·pytest
余~~185381628002 小时前
NFC 碰一碰发视频源码搭建技术详解,支持OEM
开发语言·人工智能·python·音视频
苏三有春2 小时前
PyQt实战——使用python提取JSON数据(十)
python·json·pyqt
allnlei2 小时前
自定义 Celery的logging模块
python·celery