Bootstrap

项目实训:解决python pip install PyAudio 安装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
  ╰─> [11 lines of output]
      WARNING:root:Warning: VCPKG_PATH envrionment variable not set.
      INFO:root:running bdist_wheel
      INFO:root:running build
      INFO:root:running build_py
      INFO:root:creating build
      INFO:root:creating build\lib.win-amd64-cpython-37
      INFO:root:creating build\lib.win-amd64-cpython-37\pyaudio
      INFO:root:copying src\pyaudio\__init__.py -> build\lib.win-amd64-cpython-37\pyaudio
      INFO:root:running build_ext
      INFO:root:building 'pyaudio._portaudio' extension
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [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: Could not build wheels for PyAudio, which is required to install pyproject.toml-based projects

这个错误表明安装 PyAudio 失败,因为缺少 Microsoft Visual C++ 14.0 或更高版本。这个错误表明安装 PyAudio 失败,因为缺少 Microsoft Visual C++ 14.0 或更高版本。

这里不用下载c++什么的,只需要自己从官网把这个包先下载到本地,网址

​​​​​​PyAudio · PyPI

选择合适的版本,先到python环境下查看python版本

可以看到我的web虚拟环境下的python版本是3.8,我的电脑是64位,版本号一定要对应,不然会报错。就下载PyAudio-0.2.14-cp38-cp38-win_amd64.whl 存储到D盘software目录下

然后再下运行

pip install D:\software\PyAudio-0.2.14-cp38-cp38-win_amd64.whl

即可成功

;