我无法在 windows 中安装 pyaudio

I can't install pyaudio in windows

我是 python 的初学者。我正在尝试使用 speech_recognition 模块通过 python 将语音转换为文本。当我 运行 它说,“找不到 PyAudio;检查安装”。 然后我尝试使用 pip install pyaudio 安装 pyaudio。但它给了我这个错误:

Microsoft Windows [Version 10.0.10240]
(c) 2015 Microsoft Corporation. All rights reserved.

C:\Users\PC>pip install PyAudio
Collecting PyAudio
  Using cached PyAudio-0.2.11.tar.gz (37 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: PyAudio
  Building wheel for PyAudio (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'C:\Users\PC\AppData\Local\Programs\Python\Python39\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\PC\AppData\Local\Temp\pip-install-bku61vwd\pyaudio_9e10d234344b439ca6717d882961d26a\setup.py'"'"'; __file__='"'"'C:\Users\PC\AppData\Local\Temp\pip-install-bku61vwd\pyaudio_9e10d234344b439ca6717d882961d26a\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\PC\AppData\Local\Temp\pip-wheel-k8_j_ft0'
       cwd: C:\Users\PC\AppData\Local\Temp\pip-install-bku61vwd\pyaudio_9e10d234344b439ca6717d882961d26a\
  Complete output (9 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.9
  copying src\pyaudio.py -> build\lib.win-amd64-3.9
  running build_ext
  building '_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/
  ----------------------------------------
  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\PC\AppData\Local\Programs\Python\Python39\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\PC\AppData\Local\Temp\pip-install-bku61vwd\pyaudio_9e10d234344b439ca6717d882961d26a\setup.py'"'"'; __file__='"'"'C:\Users\PC\AppData\Local\Temp\pip-install-bku61vwd\pyaudio_9e10d234344b439ca6717d882961d26a\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\PC\AppData\Local\Temp\pip-record-myk3sdkb\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\PC\AppData\Local\Programs\Python\Python39\Include\PyAudio'
         cwd: C:\Users\PC\AppData\Local\Temp\pip-install-bku61vwd\pyaudio_9e10d234344b439ca6717d882961d26a\
    Complete output (9 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.9
    copying src\pyaudio.py -> build\lib.win-amd64-3.9
    running build_ext
    building '_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/
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\PC\AppData\Local\Programs\Python\Python39\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\PC\AppData\Local\Temp\pip-install-bku61vwd\pyaudio_9e10d234344b439ca6717d882961d26a\setup.py'"'"'; __file__='"'"'C:\Users\PC\AppData\Local\Temp\pip-install-bku61vwd\pyaudio_9e10d234344b439ca6717d882961d26a\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\PC\AppData\Local\Temp\pip-record-myk3sdkb\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\PC\AppData\Local\Programs\Python\Python39\Include\PyAudio' Check the logs for full command output.

我的 Python 版本是 3.9.7。如何在我的 Windows 10 中安装 PyAudio 模块??

它在错误中说对了:

Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/

从给定的 link 下载工具,安装它们然后重试 pip install pyaudio