Python cannot install PyAudio

I. Errors and Causes

There are no wheels (pre-built packages) for Python 3.7 on Windows (one for Python 2.7 and 3.4 to 3.6), so you need to prepare the build environment on your PC to use this package. Because some packages are hard to build on Windows, it's easier to find the wheel of 3.7.

This is the error of the Installation Times:

> pip3 install pyaudio
Collecting pyaudio
  Using cached
Installing collected packages: pyaudio
  Running install for pyaudio ... error
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\upc\appdata\local\programs\python\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'E:\\Systmp\\usertmp\\pip-install-yw72dnzm\\pyaudio\\'"'"'; __file__='"'"'E:\\Systmp\\usertmp\\pip-install-yw72dnzm\\pyaudio\\'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);'"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'E:\Systmp\usertmp\pip-record-fx3j8t4l\install-record.txt' --single-version-externally-managed --compile
         cwd: E:\Systmp\usertmp\pip-install-yw72dnzm\pyaudio\
    Complete output (15 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-3.7
    copying src\ -> build\lib.win32-3.7
    running build_ext
    building '_portaudio' extension
    creating build\temp.win32-3.7
    creating build\temp.win32-3.7\Release
    creating build\temp.win32-3.7\Release\src
    D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\upc\appdata\local\programs\python\python37-32\include -Ic:\users\upc\appdata\local\programs\python\python37-32\include "-ID:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\ATLMFC\include" "-ID:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-ID:\Windows Kits\10\include\10.0.17763.0\ucrt" "-ID:\Windows Kits\10\include\10.0.17763.0\shared" "-ID:\Windows Kits\10\include\10.0.17763.0\um" "-ID:\Windows Kits\10\include\10.0.17763.0\winrt" "-ID:\Windows Kits\10\include\10.0.17763.0\cppwinrt" /Tcsrc/_portaudiomodule.c /Fobuild\temp.win32-3.7\Release\src/_portaudiomodule.obj
    src/_portaudiomodule.c(29): fatal error C1083: Unable to open Including Files: "portaudio.h": No such file or directory
    error: command 'D:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2
ERROR: Command errored out with exit status 1: 'c:\users\upc\appdata\local\programs\python\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'E:\\Systmp\\usertmp\\pip-install-yw72dnzm\\pyaudio\\'"'"'; __file__='"'"'E:\\Systmp\\usertmp\\pip-install-yw72dnzm\\pyaudio\\'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);'"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'E:\Systmp\usertmp\pip-record-fx3j8t4l\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.

II. Solutions

As a beginner, take your time and I did a search, referring to stack overflow. Answer:

  • Open the python terminal, right-click on A. py file, select Edit with IDLE - > Edit with IDLE 3.7 (32 bit) to open, and then use F5 to boot quickly, you can see all the basic information of your python, such as my version is 3.7.4, 32-bit.
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
  • Download what you need wheel To download matching wheels based on your information, for example, if it's 64 bit (AMD64), you need to download PyAudio 0.2.11 cp37 cp37m win_amd64.whl, and I need to download the last PyAudio 0.2.11 cp37 CPM win32.whl.
  • After finding the corresponding wheel to download, install it in the folder where the wheel is located.
pip3 install PyAudio-0.2.11-cp37-cp37m-win32.whl

# The following information indicates successful installation
D:\User\Downloads>pip3 install PyAudio-0.2.11-cp37-cp37m-win32.whl
Processing d:\user\downloads\pyaudio-0.2.11-cp37-cp37m-win32.whl
Installing collected packages: PyAudio
Successfully installed PyAudio-0.2.11

Tags: Python Windows pip

Posted on Wed, 09 Oct 2019 09:07:21 -0700 by stevehaysom