简体   繁体   中英

Unable to install PyAudio on Python 3.9

I'm trying to install PyAudio on Python 3.9 and it is not working. 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. I also tried downloading the following and installing it: PyAudio‑0.2.11‑cp39‑cp39‑win_amd64.whl

I am trying to build an Alexa-like AI, and need this PyAudio package.

Perhaps try pip install pipwin and then pipwin install pyaudio ? pipwin is designed to work on Windows, so you may have better luck with it.

As of today 10-03-2022, you have following options:

  • 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.
  • 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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