I am using python 3.9 and I can't figure out how to install pyaudio in my Windows 10

Nikhil Mundhra picture Nikhil Mundhra · Dec 13, 2020 · Viewed 8.2k times · Source

Currently using Visual Studio Code Tried using pip install pyaudio but it simply gave an error like:

PS C:\Users\NIKHIL> 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 files\python39\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\NIKHIL\\AppData\\Local\\Temp\\pip-install-yo0mmwlt\\pyaudio_d4ca14ee2a5246debede93cab086f909\\setup.py'"'"'; __file__='"'"'C:\\Users\\NIKHIL\\AppData\\Local\\Temp\\pip-install-yo0mmwlt\\pyaudio_d4ca14ee2a5246debede93cab086f909\\setup.py'"'"';f=getattr(tokenize, 
'"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\NIKHIL\AppData\Local\Temp\pip-wheel-cbxwzcr9'
       cwd: C:\Users\NIKHIL\AppData\Local\Temp\pip-install-yo0mmwlt\pyaudio_d4ca14ee2a5246debede93cab086f909\
  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:\program files\python39\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\NIKHIL\\AppData\\Local\\Temp\\pip-install-yo0mmwlt\\pyaudio_d4ca14ee2a5246debede93cab086f909\\setup.py'"'"'; __file__='"'"'C:\\Users\\NIKHIL\\AppData\\Local\\Temp\\pip-install-yo0mmwlt\\pyaudio_d4ca14ee2a5246debede93cab086f909\\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\NIKHIL\AppData\Local\Temp\pip-record-u900rrya\install-record.txt' --single-version-externally-managed --user --prefix= --compile --install-headers 'C:\Users\NIKHIL\AppData\Roaming\Python\Python39\Include\pyaudio'  
         cwd: C:\Users\NIKHIL\AppData\Local\Temp\pip-install-yo0mmwlt\pyaudio_d4ca14ee2a5246debede93cab086f909\
    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:\program files\python39\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\NIKHIL\\AppData\\Local\\Temp\\pip-install-yo0mmwlt\\pyaudio_d4ca14ee2a5246debede93cab086f909\\setup.py'"'"'; __file__='"'"'C:\\Users\\NIKHIL\\AppData\\Local\\Temp\\pip-install-yo0mmwlt\\pyaudio_d4ca14ee2a5246debede93cab086f909\\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\NIKHIL\AppData\Local\Temp\pip-record-u900rrya\install-record.txt' --single-version-externally-managed --user --prefix= --compile --install-headers 'C:\Users\NIKHIL\AppData\Roaming\Python\Python39\Include\pyaudio' Check the logs for full command 
output.

please suggest a way out of this

Answer

miguelcamposfernandes picture miguelcamposfernandes · Dec 13, 2020

You can also try to install it with the .whl file.

  1. Find your Python version
  2. 64 or 32 bit?
  3. Find the appropriate file here For example, my Python version is the 3.9 64bit I would download the "PyAudio‑0.2.11‑cp39‑cp39‑win_amd64.whl" file.
  4. Open your CMD and go to the folder where the file is. Ex.: cd C:\Users\Miguel\Downloads
  5. Install it: pip install PyAudio‑0.2.11‑cp39‑cp39‑win_amd64.whl

Hope it helped!