简体   繁体   English

无法在 Python 3.9 上安装 PyAudio

[英]Unable to install PyAudio on Python 3.9

I'm trying to install PyAudio on Python 3.9 and it is not working.我正在尝试在 Python 3.9 上安装 PyAudio,但它无法正常工作。 I am getting the following error:我收到以下错误:

ERROR: Command errored out with exit status 1:
     command: 'c:\users\koffie\appdata\local\programs\python\python39\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\koffie\\AppData\\Local\\Temp\\pip-install-8fxj755j\\pyaudio_3c7b865f50cd493eaf257dea132d1fe1\\setup.py'"'"'; __file__='"'"'C:\\Users\\koffie\\AppData\\Local\\Temp\\pip-install-8fxj755j\\pyaudio_3c7b865f50cd493eaf257dea132d1fe1\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\koffie\AppData\Local\Temp\pip-record-9go3oms0\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\koffie\appdata\local\programs\python\python39\Include\pyaudio'   
         cwd: C:\Users\koffie\AppData\Local\Temp\pip-install-8fxj755j\pyaudio_3c7b865f50cd493eaf257dea132d1fe1\
    Complete output (17 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
    creating build\temp.win-amd64-3.9
    creating build\temp.win-amd64-3.9\Release
    creating build\temp.win-amd64-3.9\Release\src
    C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29910\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DMS_WIN64=1 -Ic:\users\koffie\appdata\local\programs\python\python39\include -Ic:\users\koffie\appdata\local\programs\python\python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29910\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.    _portaudiomodule.c
    c:\users\koffie\appdata\local\programs\python\python39\include\pyconfig.h(117): warning C4005: 'MS_WIN64': macro redefinition
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.28.29910\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\koffie\appdata\local\programs\python\python39\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\koffie\\AppData\\Local\\Temp\\pip-install-8fxj755j\\pyaudio_3c7b865f50cd493eaf257dea132d1fe1\\setup.py'"'"'; __file__='"'"'C:\\Users\\koffie\\AppData\\Local\\Temp\\pip-install-8fxj755j\\pyaudio_3c7b865f50cd493eaf257dea132d1fe1\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\koffie\AppData\Local\Temp\pip-record-9go3oms0\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\koffie\appdata\local\programs\python\python39\Include\pyaudio' Check the logs for full command output.

I have tried downloading Visual Basic Tools, as well as, I have tried doing the pip install pipwin and then PyAudio function. But unfortunately the same error occurred.我试过下载 Visual Basic Tools,也试过 pip 安装 pipwin,然后是 PyAudio function。但不幸的是,同样的错误发生了。 I also tried downloading the following and installing it: PyAudio‑0.2.11‑cp39‑cp39‑win_amd64.whl我还尝试下载并安装以下内容:PyAudio‑0.2.11‑cp39‑cp39‑win_amd64.whl

I am trying to build an Alexa-like AI, and need this PyAudio package.我正在尝试构建一个类似 Alexa 的 AI,并且需要这个 PyAudio package。

Perhaps try pip install pipwin and then pipwin install pyaudio ?也许尝试pip install pipwin然后pipwin install pyaudio pipwin is designed to work on Windows, so you may have better luck with it. pipwin 旨在在 Windows 上工作,所以你可能会有更好的运气。

As of today 10-03-2022, you have following options:从今天 10-03-2022 开始,您有以下选择:

  • use python 3.6 (wheels available), probably you don't want to give up on the latest python version because of this dependency, but this is an easy option.使用 python 3.6(可用轮子),可能你不想因为这种依赖而放弃最新的 python 版本,但这是一个简单的选择。
  • you build it from source, probably will take you some effort.您从源代码构建它,可能会花费您一些精力。
  • you download the wheel package from gohlke's page and tell pip to use that wheel instead of downloading it from pypi.你从gohlke 的页面下载 wheel package 并告诉 pip 使用那个 wheel 而不是从 pypi 下载它。

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

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