Search code examples
pythonpython-3.xpyaudio

PyAudio Windows 10 installation error on wheel and on setup.py


I'm using Python 3.8.3.

I tried to install PyAudio by using pip install pyaudio. But I got a wheel error and also an error related to setup.py of PyAudio.

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\17326\pycharmprojects\voice\venv\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\17326\\AppData\\Local\\Temp\\pip-install-
1t8lu494\\pyaudio\\setup.py'"'"'; __file__='"'"'C:\\Users\\17326\\AppData\\Local\\Temp\\pip-install-1t8lu494\\pyaudio\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);co
de=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\17326\AppData\Local\Temp\pip-wheel-3y_f6xu3'
       cwd: C:\Users\17326\AppData\Local\Temp\pip-install-1t8lu494\pyaudio\
  Complete output (15 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win32-3.8
  copying src\pyaudio.py -> build\lib.win32-3.8
  running build_ext
  building '_portaudio' extension
  creating build\temp.win32-3.8
  creating build\temp.win32-3.8\Release
  creating build\temp.win32-3.8\Release\src
  C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.26.28801\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\17326\pycharmprojects\voic
e\venv\include -IC:\Users\17326\AppData\Local\Programs\Python\Python38-32\include -IC:\Users\17326\AppData\Local\Programs\Python\Python38-32\include "-IC:\Program Files (x86)\Microsoft Vi
sual Studio\2019\BuildTools\VC\Tools\MSVC\14.26.28801\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.
18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows
Kits\10\include\10.0.18362.0\cppwinrt" /Tcsrc/_portaudiomodule.c /Fobuild\temp.win32-3.8\Release\src/_portaudiomodule.obj
  _portaudiomodule.c
  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\\BuildTools\\VC\\Tools\\MSVC\\14.26.28801\\bin\\HostX86\\x86\\cl.exe' failed with exit status 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\17326\pycharmprojects\voice\venv\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\17326\\AppData\\Local\\Temp\\pip-instal
l-1t8lu494\\pyaudio\\setup.py'"'"'; __file__='"'"'C:\\Users\\17326\\AppData\\Local\\Temp\\pip-install-1t8lu494\\pyaudio\\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\17326\AppData\Local\Temp\pip-record-quacxxz7\instal
l-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\17326\pycharmprojects\voice\venv\include\site\python3.8\pyaudio'
         cwd: C:\Users\17326\AppData\Local\Temp\pip-install-1t8lu494\pyaudio\
    Complete output (15 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-3.8
    copying src\pyaudio.py -> build\lib.win32-3.8
    running build_ext
    building '_portaudio' extension
    creating build\temp.win32-3.8
    creating build\temp.win32-3.8\Release
    creating build\temp.win32-3.8\Release\src
    C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.26.28801\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\17326\pycharmprojects\vo
ice\venv\include -IC:\Users\17326\AppData\Local\Programs\Python\Python38-32\include -IC:\Users\17326\AppData\Local\Programs\Python\Python38-32\include "-IC:\Program Files (x86)\Microsoft
Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.26.28801\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.
0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Window
s Kits\10\include\10.0.18362.0\cppwinrt" /Tcsrc/_portaudiomodule.c /Fobuild\temp.win32-3.8\Release\src/_portaudiomodule.obj
    _portaudiomodule.c
    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\\BuildTools\\VC\\Tools\\MSVC\\14.26.28801\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\17326\pycharmprojects\voice\venv\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\17326\
\AppData\\Local\\Temp\\pip-install-1t8lu494\\pyaudio\\setup.py'"'"'; __file__='"'"'C:\\Users\\17326\\AppData\\Local\\Temp\\pip-install-1t8lu494\\pyaudio\\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\17326\AppData\Loca
l\Temp\pip-record-quacxxz7\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\17326\pycharmprojects\voice\venv\include\site\python3.8\pyaudio' C
heck the logs for full command output.

Then I googled a bit and I found here. So I installed PyAudio-0.2.11-cp39-cp39-win_amd64.whl.

When I type pip install PyAudio-0.2.11-cp39-cp39-win_amd64.whl, I got an error ERROR: PyAudio-0.2.11-cp39-cp39-win_amd64.whl is not a supported wheel on this platform.

After that, I searched on Stack Overflow. I saw someone has answered by saying:

Try this:

pip install pipwin
pipwin install pyaudio

pipwin is like pip, but it installs precompiled Windows binaries provided by Christoph Gohlke. Saves you a lot of googling and manual downloading.

But when I use this, I got the following error:

Package `pyaudio` found in cache
Downloading package . . .
https://download.lfd.uci.edu/pythonlibs/w3jqiv8s/PyAudio-0.2.11-cp38-cp38-win32.whl
PyAudio-0.2.11-cp38-cp38-win32.whl
Traceback (most recent call last):
  File "C:\Users\17326\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\17326\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\17326\PycharmProjects\Voice\venv\Scripts\pipwin.exe\__main__.py", line 7, in <module>
  File "c:\users\17326\pycharmprojects\voice\venv\lib\site-packages\pipwin\command.py", line 98, in main
    cache.install(package)
  File "c:\users\17326\pycharmprojects\voice\venv\lib\site-packages\pipwin\pipwin.py", line 300, in install
    wheel_file = self.download(requirement)
  File "c:\users\17326\pycharmprojects\voice\venv\lib\site-packages\pipwin\pipwin.py", line 294, in download
    return self._download(requirement, dest)
  File "c:\users\17326\pycharmprojects\voice\venv\lib\site-packages\pipwin\pipwin.py", line 290, in _download
    obj.start()
  File "c:\users\17326\pycharmprojects\voice\venv\lib\site-packages\pySmartDL\pySmartDL.py", line 267, in start
    urlObj = urllib.request.urlopen(req, timeout=self.timeout, context=self.context)
  File "C:\Users\17326\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "C:\Users\17326\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 531, in open
    response = meth(req, response)
  File "C:\Users\17326\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 640, in http_response
    response = self.parent.error(
  File "C:\Users\17326\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 569, in error
    return self._call_chain(*args)
  File "C:\Users\17326\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 502, in _call_chain
    result = func(*args)
  File "C:\Users\17326\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found

From what I see, the source used by pipwin is out of date-deleted, so I get this error.

Is there any other way to do this?


Solution

  • You need to make sure you have the correct version of pyaudio, for instance, cp38 means CPython 3.8. You also need to make sure you are downloading the correct type, so if you have 32-bit python you want the file that has win32, and for 64-bit you want the win_amd64. For your case you want PyAudio‑0.2.11‑cp38‑cp38‑win32.whl, because it is for 32-bit CPython 3.8.