When I am trying to install PyAudio using
pip install pyaudio
I get this error:
C:Userspankajkaun>pip install pyaudio
Collecting pyaudio
Using cached https://files.pythonhosted.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gz
Installing collected packages: pyaudio
Running setup.py install for pyaudio ... error
Complete output from command c:userspankajkaundesktoppythonpython.exe -u -c "import setuptools, tokenize;__file__='C:\Users\PANKAJ~1\AppData\Local\Temp\pip-install-pw8_ueh5\pyaudio
\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('rn', 'n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:UsersPANKAJ~1AppDataLocalTemp
pip-record-eru_9orvinstall-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating buildlib.win-amd64-3.7
copying srcpyaudio.py -> buildlib.win-amd64-3.7
running build_ext
building '_portaudio' extension
creating buildtemp.win-amd64-3.7
creating buildtemp.win-amd64-3.7Release
creating buildtemp.win-amd64-3.7Releasesrc
C:Program Files (x86)Microsoft Visual Studio2017BuildToolsVCToolsMSVC14.16.27023binHostX86x64cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DMS_WIN64=1 -Ic:userspankajkaundesktoppythoninclude -Ic:userspankajkaundesktoppython
include "-IC:Program Files (x86)Microsoft Visual Studio2017BuildToolsVCToolsMSVC14.16.27023include" "-IC:Program Files (x86)Windows Kits10include10.0.17763.0ucrt" "-
IC:Program Files (x86)Windows Kits10include10.0.17763.0shared" "-IC:Program Files (x86)Windows Kits10include10.0.17763.0um" "-IC:Program Files (x86)Windows Kits10include10.0.17763.0winrt" "-IC:
Program Files (x86)Windows Kits10include10.0.17763.0cppwinrt" /Tcsrc/_portaudiomodule.c /Fobuildtemp.win-amd64-3.7Releasesrc/_portaudiomodule.obj
_portaudiomodule.c
c:userspankajkaundesktoppythonincludepyconfig.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\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe' failed with exit status 2
----------------------------------------
Command "c:userspankajkaundesktoppythonpython.exe -u -c "import setuptools, tokenize;__file__='C:\Users\PANKAJ~1\AppData\Local\Temp\pip-install-pw8_ueh5\pyaudio
\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('rn', 'n');f.close();exec(compile(code, __file__, 'exec'))" install --record
C:UsersPANKAJ~1AppDataLocalTemppip-record-eru_9orvinstall-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:UsersPANKAJ~1AppDataLocalTemppip-install-pw8_ueh5pyaudio
Any idea what’s going on in here?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Try this (in admin mode command prompt):
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.
Method 2
According to official docs of pyaudio:
Microsoft Windows
Install using pip:
python -m pip install pyaudio
Notes: pip will fetch and install PyAudio wheels (prepackaged binaries). Currently, there are wheels compatible with the official distributions of Python 2.7, 3.4, 3.5, and 3.6. For those versions, both 32-bit and 64-bit wheels are available.
You try to install pyaudio for 3.7, so it try to compile it.
Download and install wheel from Gohlke – Unofficial Windows Binaries for Python Extension Packages. Wheels for 32 and 64-bit python 3.7 are available.
Method 3
Use this link to download the .whl file according to the python version it supports:
https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio
Then, go to the following directory and run this command on the command prompt:
C:UsersshrisAppDataLocalProgramsPythonPython37-32Scripts> pip install PyAudio-0.2.11-cp37-cp37m-win32.whl
Method 4
Run CMD as admin then run the following two commands:
- pip install pipwin
- pipwin install pyaudio
Method 5
I had the same issue and I solved it by using the WHL file which you can download from:
https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio.
There are several versions that you can download and use.
For example, PyAudio-0.2.11-cp37-cp37m-win_amd64.whl.
For installing purposes on the command prompt, write
pip install "path"PyAudio-0.2.11-cp37-cp37m-win_amd64.whl
Method 6
It seems you need to install portaudio first.
Method 7
Here is my computer configuration:
- Windows 10
- Python 3.8.0 installed on
C:Program Files (x86)PythonPython38-32
I’ve got the same issue and i solved it with these steps:
-
download PyAudio‑0.2.11‑cp38‑cp38‑win32.whl from here on my computer in
C:DownloadsPyAudio-0.2.11-cp38-cp38-win32.whl -
run
C:Program Files (x86)PythonPython38-32Scripts>pip3.8 install C:DownloadsPyAudio-0.2.11-cp38-cp38-win32.whl --user
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0