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

Windows 11系统pip安装PyAudio失败报错问题咨询

Windows 11 环境pip安装PyAudio失败处理

报错日志

Collecting pyaudio
  Using cached PyAudio-0.2.11.tar.gz (37 kB)
Building wheels for collected packages: pyaudio
  Building wheel for pyaudio (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'c:\users\singh\appdata\local\programs\python\python38\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\singh\\AppData\\Local\\Temp\\pip-install-84dt8r3e\\pyaudio_93a7719f57d74959a2374b9d3da284f9\\setup.py'"'"'; __file__='"'"'C:\\Users\\singh\\AppData\\Local\\Temp\\pip-install-84dt8r3e\\pyaudio_93a7719f57d74959a2374b9d3da284f9\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\singh\AppData\Local\Temp\pip-wheel-jd1xu2pm'
       cwd: C:\Users\singh\AppData\Local\Temp\pip-install-84dt8r3e\pyaudio_93a7719f57d74959a2374b9d3da284f9\
  Complete output (9 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.8
  copying src\pyaudio.py -> build\lib.win-amd64-3.8
  running build_ext
  building '_portaudio' extension
  error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/
  ----------------------------------------
  ERROR: Failed building wheel for pyaudio
  Running setup.py clean for pyaudio
Failed to build pyaudio
Installing collected packages: pyaudio
    Running setup.py install for pyaudio ... error
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\singh\appdata\local\programs\python\python38\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\singh\\AppData\\Local\\Temp\\pip-install-84dt8r3e\\pyaudio_93a7719f57d74959a2374b9d3da284f9\\setup.py'"'"'; __file__='"'"'C:\\Users\\singh\\AppData\\Local\\Temp\\pip-install-84dt8r3e\\pyaudio_93a7719f57d74959a2374b9d3da284f9\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\singh\AppData\Local\Temp\pip-record-7zj32_tv\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\singh\appdata\local\programs\python\python38\Include\pyaudio'
         cwd: C:\Users\singh\AppData\Local\Temp\pip-install-84dt8r3e\pyaudio_93a7719f57d74959a2374b9d3da284f9\
    Complete output (9 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.8
    copying src\pyaudio.py -> build\lib.win-amd64-3.8
    running build_ext
    building '_portaudio' extension
    error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\singh\appdata\local\programs\python\python38\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\singh\\AppData\\Local\\Temp\\pip-install-84dt8r3e\\pyaudio_93a7719f57d74959a2374b9d3da284f9\\setup.py'"'"'; __file__='"'"'C:\\Users\\singh\\AppData\\Local\\Temp\\pip-install-84dt8r3e\\pyaudio_93a7719f57d74959a2374b9d3da284f9\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\singh\AppData\Local\Temp\pip-record-7zj32_tv\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\singh\appdata\local\programs\python\python38\Include\pyaudio' Check the logs for full command output.

错误原因

PyAudio官方未提供适配Windows平台Python3.8及以上版本的预编译wheel包,直接执行pip安装时需要从源码编译依赖的portaudio组件,本地缺少Microsoft Visual C++ 14.0编译环境会导致编译流程终止,安装失败。

解决方法

方案一:使用pipwin安装预编译包(优先推荐,无需安装编译环境)

pipwin是针对Windows平台的pip辅助工具,会自动匹配对应Python版本、系统架构的预编译第三方库安装包,避开源码编译流程。

  • 执行命令安装pipwin:pip install pipwin
  • 安装完成后执行命令安装PyAudio:pipwin install pyaudio

方案二:安装编译环境(适合需要从源码编译其他C扩展的场景)

安装Microsoft Visual Studio生成工具,安装过程中勾选「使用C++的桌面开发」组件,等待安装完成重启终端后,重新执行pip install pyaudio即可。

内容的提问来源于stack exchange,提问作者Amarendra Singh

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.30 15:36:03