You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

运行程序提示未找到PyAudio,pip安装时报错缺少VC++14.0如何解决

PyAudio安装失败、运行报找不到模块的解决方法

运行依赖音频采集能力的Python代码时,常见如下报错:

AttributeError: Could not find PyAudio; check installation(属性错误:未找到PyAudio,请检查安装状态)

直接执行pip install pyaudio命令尝试安装依赖时,终端返回报错信息如下:

PS E:\MU\Sem 4\JARVIS\CODE> pip install pyaudio 
Collecting pyaudio
  Using cached PyAudio-0.2.11.tar.gz (37 kB)
  Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for pyaudio, since package 'wheel' is not installed.
Installing collected packages: pyaudio
  Running setup.py install for pyaudio ... error
  error: subprocess-exited-with-error

  × Running setup.py install for pyaudio did not run successfully.
  │ exit code: 1
  ╰─> [9 lines of output]
      running install
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-3.10
      copying src\pyaudio.py -> build\lib.win-amd64-3.10
      running build_ext
      building '_portaudio' extension
      error: Microsoft Visual C++ 14.0 or greater is required. Install Microsoft C++ Build Tools to get the required compilation environment.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> pyaudio

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

核心报错原因

PyAudio安装过程需要编译_portaudio底层扩展,本地环境缺少Microsoft Visual C++ 14.0及以上版本的编译工具链时,编译流程会直接中断,导致PyAudio没有被正确安装到Python环境中,运行相关代码时就会抛出找不到PyAudio的属性错误。

可用解决方法

任选一种方式操作即可完成安装:

  • 安装Microsoft C++ Build Tools,安装时勾选「使用C++的桌面开发」组件,安装完成后重启终端,重新执行pip install pyaudio即可走源码编译流程正常完成安装
  • 先执行pip install wheel安装wheel包管理组件,自行下载和本地Python版本、系统架构(32/64位)匹配的PyAudio预编译whl安装包,进入whl包所在的文件夹路径,执行pip install 下载得到的whl包完整文件名即可跳过本地编译步骤直接安装
  • 执行pip install pipwin安装pipwin工具,工具安装完成后执行pipwin install pyaudio,工具会自动识别当前系统、Python版本,下载匹配的预编译PyAudio包自动完成安装,无需手动查找安装资源

内容的提问来源于stack exchange,提问作者Harsh Majethia

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.29 06:22:03