简体   繁体   English

无法在 Windows 10、python 3.9.5 上安装 PyAudio

[英]Can't install PyAudio on windows 10, python 3.9.5

Trying to download PyAudio by pip install PyAudio but this isn't working.尝试通过pip install PyAudio下载 PyAudio 但这不起作用。 I'm using Python 3.9.5 also tried python -m pip install pyaudio but it didn't work.我正在使用 Python 3.9.5 也尝试过python -m pip install pyaudio但它没有用。 Anyone having the same error??有人有同样的错误吗?? help me solve this error please...请帮我解决这个错误...

see the code below for reference ↓参考下面的代码↓

    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\keepa\appdata\local\programs\python\python39\python.exe' -u
-c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\keepa\\AppData\\Local\\Temp\\pip-install-e979x4nc\\pyaudio_403fcffb6b004552a1d48ac0e0876dd8\\setup.py'"'"';
__file__='"'"'C:\\Users\\keepa\\AppData\\Local\\Temp\\pip-install-e979x4nc\\pyaudio_403fcffb6b004552a1d48ac0e0876dd8\\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\keepa\AppData\Local\Temp\pip-wheel-trp3euxd'
           cwd: C:\Users\keepa\AppData\Local\Temp\pip-install-e979x4nc\pyaudio_403fcffb6b004552a1d48ac0e0876dd8\
      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\keepa\appdata\local\programs\python\python39\python.exe' -u
-c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\keepa\\AppData\\Local\\Temp\\pip-install-e979x4nc\\pyaudio_403fcffb6b004552a1d48ac0e0876dd8\\setup.py'"'"';
__file__='"'"'C:\\Users\\keepa\\AppData\\Local\\Temp\\pip-install-e979x4nc\\pyaudio_403fcffb6b004552a1d48ac0e0876dd8\\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\keepa\AppData\Local\Temp\pip-record-isa75oeg\install-record.txt'
--single-version-externally-managed --compile --install-headers 'c:\users\keepa\appdata\local\programs\python\python39\Include\PyAudio'
             cwd: C:\Users\keepa\AppData\Local\Temp\pip-install-e979x4nc\pyaudio_403fcffb6b004552a1d48ac0e0876dd8\
        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\keepa\appdata\local\programs\python\python39\python.exe' -u
-c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\keepa\\AppData\\Local\\Temp\\pip-install-e979x4nc\\pyaudio_403fcffb6b004552a1d48ac0e0876dd8\\setup.py'"'"';
__file__='"'"'C:\\Users\\keepa\\AppData\\Local\\Temp\\pip-install-e979x4nc\\pyaudio_403fcffb6b004552a1d48ac0e0876dd8\\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\keepa\AppData\Local\Temp\pip-record-isa75oeg\install-record.txt'
--single-version-externally-managed --compile --install-headers 'c:\users\keepa\appdata\local\programs\python\python39\Include\PyAudio' Check the logs for full command output.

When running python 3.6 this works, but with python 3.7 it doesn't.运行 python 3.6 时,这有效,但使用 python 3.7 时无效。

PyAudio only supports up to python 3.6: PyAudio 最多只支持 python 3.6:

pip will fetch and install PyAudio wheels (prepackaged binaries). Currently, there are wheels compatible with the official distributions of Python 2.7, 3.4, 3.5, and 3.6.

The workarounds would be to use a supported version of python, or to build and install manually - if the latter, you'll need to make sure you have the correct libraries installed and configured.解决方法是使用受支持的 python 版本,或者手动构建和安装 - 如果是后者,您需要确保安装和配置了正确的库。

I should point out that PyAudio appears to be deprecated.我应该指出 PyAudio 似乎已被弃用。 It hasn't received an update since March 2017. Therefore I recommend you find another package for this.它自 2017 年 3 月以来没有收到更新。因此我建议您为此找到另一个包。

Same problem due to the absence of Microsoft compiler that i didn't want to install on my PC.由于我不想在我的 PC 上安装 Microsoft 编译器,因此出现了同样的问题。 I used this website unofficial pre-compiled pyaudio wheel packages, it worked well.我使用了这个网站非官方的预编译 pyaudio 轮包,效果很好。 So download wheel files at this site: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio Of course, download the wheel version that is compatible with your python version.所以在这个站点下载wheel文件: https : //www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio当然,下载与你的python版本兼容的wheel版本。

use the command: pip install wheel_file_downloaded使用命令:pip install wheel_file_downloaded

pip install pipwin
python -m pipwin install pyaudio

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM