我正在使用python3.9,但我不知道如何在我的Windows10中安装pyaudio

当前使用 Visual Studio Code 尝试使用pip install pyaudio但它只是给出了一个错误,如:

PS C:UsersNIKHIL> pip install pyaudio
Defaulting to user installation because normal site-packages is 
not writeable
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:program filespython39python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:UsersNIKHILAppDataLocalTemppip-install-yo0mmwltpyaudio_d4ca14ee2a5246debede93cab086f909setup.py'"'"'; __file__='"'"'C:UsersNIKHILAppDataLocalTemppip-install-yo0mmwltpyaudio_d4ca14ee2a5246debede93cab086f909setup.py'"'"';f=getattr(tokenize, 
'"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:UsersNIKHILAppDataLocalTemppip-wheel-cbxwzcr9'
       cwd: C:UsersNIKHILAppDataLocalTemppip-install-yo0mmwltpyaudio_d4ca14ee2a5246debede93cab086f909
  Complete output (9 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating buildlib.win-amd64-3.9
  copying srcpyaudio.py -> buildlib.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:program filespython39python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:UsersNIKHILAppDataLocalTemppip-install-yo0mmwltpyaudio_d4ca14ee2a5246debede93cab086f909setup.py'"'"'; __file__='"'"'C:UsersNIKHILAppDataLocalTemppip-install-yo0mmwltpyaudio_d4ca14ee2a5246debede93cab086f909setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:UsersNIKHILAppDataLocalTemppip-record-u900rryainstall-record.txt' --single-version-externally-managed --user --prefix= --compile --install-headers 'C:UsersNIKHILAppDataRoamingPythonPython39Includepyaudio'  
         cwd: C:UsersNIKHILAppDataLocalTemppip-install-yo0mmwltpyaudio_d4ca14ee2a5246debede93cab086f909
    Complete output (9 lines):
    running install
    running build
    running build_py
    creating build
    creating buildlib.win-amd64-3.9
    copying srcpyaudio.py -> buildlib.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:program filespython39python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:UsersNIKHILAppDataLocalTemppip-install-yo0mmwltpyaudio_d4ca14ee2a5246debede93cab086f909setup.py'"'"'; __file__='"'"'C:UsersNIKHILAppDataLocalTemppip-install-yo0mmwltpyaudio_d4ca14ee2a5246debede93cab086f909setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:UsersNIKHILAppDataLocalTemppip-record-u900rryainstall-record.txt' --single-version-externally-managed --user --prefix= --compile --install-headers 'C:UsersNIKHILAppDataRoamingPythonPython39Includepyaudio' Check the logs for full command 
output.

请提出解决办法

回答

您也可以尝试使用 .whl 文件安装它。

  1. 查找您的 Python 版本
  2. 64位还是32位?
  3. 在这里找到合适的文件
    例如,我的 Python 版本是 3.9 64bit 我会下载“PyAudio?0.2.11?cp39?cp39?win_amd64.whl”文件。
  4. 打开您的 CMD 并转到文件所在的文件夹。例如:cd C:UsersMiguelDownloads
  5. 安装:pip install PyAudio?0.2.11?cp39?cp39?win_amd64.whl

希望有帮助!


以上是我正在使用python3.9,但我不知道如何在我的Windows10中安装pyaudio的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>