简体   繁体   中英

Cannot Install PyAudio On System

So I recently tried to install the PyAudio module to my system because it is needed for the speech recognition module, but when I typed the following command into cmd, or any command prompt/powershell for that matter: pip install PyAudio And that returns:

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\alvin\appdata\local\programs\python\python39\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\alvin\\AppData\\Local\\Temp\\pip-install-gdeagaoz\\pyaudio_da59889f6d004e64a286d2fc675cc90a\\setup.py'"'"'; __file__='"'"'C:\\Users\\alvin\\AppData\\Local\\Temp\\pip-install-gdeagaoz\\pyaudio_da59889f6d004e64a286d2fc675cc90a\\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\alvin\AppData\Local\Temp\pip-wheel-po5nhrnw'
       cwd: C:\Users\alvin\AppData\Local\Temp\pip-install-gdeagaoz\pyaudio_da59889f6d004e64a286d2fc675cc90a\
  Complete output (17 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
  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\Community\VC\Tools\MSVC\14.28.29910\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DMS_WIN64=1 -Ic:\users\alvin\appdata\local\programs\python\python39\include -Ic:\users\alvin\appdata\local\programs\python\python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\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.0\cppwinrt /Tcsrc/_portaudiomodule.c /Fobuild\temp.win-amd64-3.9\Release\src/_portaudiomodule.obj
  _portaudiomodule.c
  c:\users\alvin\appdata\local\programs\python\python39\include\pyconfig.h(117): warning C4005: 'MS_WIN64': macro redefinition
  src/_portaudiomodule.c: note: see previous definition of 'MS_WIN64'
  src/_portaudiomodule.c(29): fatal error C1083: Cannot open include file: 'portaudio.h': No such file or directory
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.28.29910\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
  ----------------------------------------
  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\alvin\appdata\local\programs\python\python39\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\alvin\\AppData\\Local\\Temp\\pip-install-gdeagaoz\\pyaudio_da59889f6d004e64a286d2fc675cc90a\\setup.py'"'"'; __file__='"'"'C:\\Users\\alvin\\AppData\\Local\\Temp\\pip-install-gdeagaoz\\pyaudio_da59889f6d004e64a286d2fc675cc90a\\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\alvin\AppData\Local\Temp\pip-record-j51eiiwc\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\alvin\appdata\local\programs\python\python39\Include\PyAudio'
         cwd: C:\Users\alvin\AppData\Local\Temp\pip-install-gdeagaoz\pyaudio_da59889f6d004e64a286d2fc675cc90a\
    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\Community\VC\Tools\MSVC\14.28.29910\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DMS_WIN64=1 -Ic:\users\alvin\appdata\local\programs\python\python39\include -Ic:\users\alvin\appdata\local\programs\python\python39\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\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.0\cppwinrt /Tcsrc/_portaudiomodule.c /Fobuild\temp.win-amd64-3.9\Release\src/_portaudiomodule.obj
    _portaudiomodule.c
    c:\users\alvin\appdata\local\programs\python\python39\include\pyconfig.h(117): warning C4005: 'MS_WIN64': macro redefinition
    src/_portaudiomodule.c: note: see previous definition of 'MS_WIN64'
    src/_portaudiomodule.c(29): fatal error C1083: Cannot open include file: 'portaudio.h': No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\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\alvin\appdata\local\programs\python\python39\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\alvin\\AppData\\Local\\Temp\\pip-install-gdeagaoz\\pyaudio_da59889f6d004e64a286d2fc675cc90a\\setup.py'"'"'; __file__='"'"'C:\\Users\\alvin\\AppData\\Local\\Temp\\pip-install-gdeagaoz\\pyaudio_da59889f6d004e64a286d2fc675cc90a\\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\alvin\AppData\Local\Temp\pip-record-j51eiiwc\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\alvin\appdata\local\programs\python\python39\Include\PyAudio' Check the logs for full command output.

I searched for it on google to find help but everybody just said th same thing, which is that I should go onto https://www.lfd.uci.edu/~gohlke/pythonlibs/ and get the.whl file But then It returns:

ERROR: PyAudio-0.2.11-cp27-cp27m-win32.whl is not a supported wheel on this platform.

Does anyone know how to fix this? Sincerely, Alvin*

Follow this:

On macOS:

brew install portaudio
brew link portaudio
pip install pyAudio

On Windows:

Go to: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio

Download the file and then go to its directory in the cmd and type:

For Win 32 bit:

pip install PyAudio‑0.2.11‑cp37‑cp37m‑win32.whl

For Win 64 bit:

pip install PyAudio‑0.2.11‑cp38‑cp38‑win_amd64.whl

I hope this is useful for you.

Regards.

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