Search code examples
pythonpippyaudio

I can't install pyaudio in windows


I'm beginner in python. I was trying to convert voice to text with python using speech_recognition module. When I run it it says, "Could not find PyAudio; check installation". then I tried to install pyaudio with pip install pyaudio. But It gives me this error:

Microsoft Windows [Version 10.0.10240]
(c) 2015 Microsoft Corporation. All rights reserved.

C:\Users\PC>pip install PyAudio
Collecting PyAudio
  Using cached PyAudio-0.2.11.tar.gz (37 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: PyAudio
  Building wheel for PyAudio (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'C:\Users\PC\AppData\Local\Programs\Python\Python39\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\PC\\AppData\\Local\\Temp\\pip-install-bku61vwd\\pyaudio_9e10d234344b439ca6717d882961d26a\\setup.py'"'"'; __file__='"'"'C:\\Users\\PC\\AppData\\Local\\Temp\\pip-install-bku61vwd\\pyaudio_9e10d234344b439ca6717d882961d26a\\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\PC\AppData\Local\Temp\pip-wheel-k8_j_ft0'
       cwd: C:\Users\PC\AppData\Local\Temp\pip-install-bku61vwd\pyaudio_9e10d234344b439ca6717d882961d26a\
  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\PC\AppData\Local\Programs\Python\Python39\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\PC\\AppData\\Local\\Temp\\pip-install-bku61vwd\\pyaudio_9e10d234344b439ca6717d882961d26a\\setup.py'"'"'; __file__='"'"'C:\\Users\\PC\\AppData\\Local\\Temp\\pip-install-bku61vwd\\pyaudio_9e10d234344b439ca6717d882961d26a\\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\PC\AppData\Local\Temp\pip-record-myk3sdkb\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\PC\AppData\Local\Programs\Python\Python39\Include\PyAudio'
         cwd: C:\Users\PC\AppData\Local\Temp\pip-install-bku61vwd\pyaudio_9e10d234344b439ca6717d882961d26a\
    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\PC\AppData\Local\Programs\Python\Python39\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\PC\\AppData\\Local\\Temp\\pip-install-bku61vwd\\pyaudio_9e10d234344b439ca6717d882961d26a\\setup.py'"'"'; __file__='"'"'C:\\Users\\PC\\AppData\\Local\\Temp\\pip-install-bku61vwd\\pyaudio_9e10d234344b439ca6717d882961d26a\\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\PC\AppData\Local\Temp\pip-record-myk3sdkb\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\PC\AppData\Local\Programs\Python\Python39\Include\PyAudio' Check the logs for full command output.

My Python version is 3.9.7. How to can I install PyAudio module in My Windows 10??


Solution

  • It says it right in the 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/

    Download the tools from the given link, install them then try pip install pyaudio again.