3

I am building a speech recognition program but can't install pyAudio.

I have installed Microsoft visual c++ 14.0.0 but still, I am getting another error. I can't understand what is going wrong here please help me out.

 ERROR: Command errored out with exit status 1:
         command: 'c:\users\udit\appdata\local\programs\python\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv\[0\] = '"'"'C:\\Users\\udit\\AppData\\Local\\Temp\\pip-install-68co_fpl\\pyaudio\\setup.py'"'"'; __file__='"'"'C:\\Users\\udit\\AppData\\Local\\Temp\\pip-install-68co_fpl\\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\udit\AppData\Local\Temp\pip-record-ih2tcx4k\install-record.txt' --single-version-externally-managed --compile
             cwd: C:\Users\udit\AppData\Local\Temp\pip-install-68co_fpl\pyaudio\
        Complete output (16 lines):
        running install
        running build
        running build_py
        creating build
        creating build\lib.win32-3.7
        copying src\pyaudio.py -> build\lib.win32-3.7
        running build_ext
        building '_portaudio' extension
        b'\\\x00C\x00o\x00m\x00m\x00o\x00n\x00 \x00w\x00a\x00s\x00 \x00u\x00n\x00e\x00x\x00p\x00e\x00c\x00t\x00e\x00d\x00 \x00a\x00t\x00 \x00t\x00h\x00i\x00s\x00 \x00t\x00i\x00m\x00e\x00.\x00\r\x00\n\x00'
        creating build\temp.win32-3.7
        creating build\temp.win32-3.7\Release
        creating build\temp.win32-3.7\Release\src
        C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\Bin\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\udit\appdata\local\programs\python\python37-32\include -Ic:\users\udit\appdata\local\programs\python\python37-32\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\Include" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\Include" "-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\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" /Tcsrc/_portaudiomodule.c /Fobuild\temp.win32-3.7\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 14.0\\VC\\Bin\\cl.exe' failed with exit status 2
        ----------------------------------------
    ERROR: Command errored out with exit status 1: 'c:\users\udit\appdata\local\programs\python\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv\[0\] = '"'"'C:\\Users\\udit\\AppData\\Local\\Temp\\pip-install-68co_fpl\\pyaudio\\setup.py'"'"'; __file__='"'"'C:\\Users\\udit\\AppData\\Local\\Temp\\pip-install-68co_fpl\\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\udit\AppData\Local\Temp\pip-record-ih2tcx4k\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.
Dinko Pehar
  • 5,454
  • 4
  • 23
  • 57
Anjali
  • 187
  • 1
  • 4
  • 12
  • Possible duplicate of [Python package installation issues: PyAudio, PortAudio](https://stackoverflow.com/questions/51992375/python-package-installation-issues-pyaudio-portaudio) – Dinko Pehar Aug 24 '19 at 16:54
  • Try this CMD as administrator : pip install pipwin / pipwin install pyaudio – hassanzadeh.sd Jan 04 '20 at 21:10

4 Answers4

4

These are notes for installation on Microsoft Windows:

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 are using Python 3.7, which is not compatible with PyAudio. However...

EDIT:

As user @Dalen states, there are prebuilt binaries (.exe files) for pyAudio. I installed from their archive stated in documentation but importing pyAudio had an output:

Windows python

There are unofficial binaries for Windows on this site: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio .

Download the proper one and install it.

Dinko Pehar
  • 5,454
  • 4
  • 23
  • 57
  • I'm not having any issues running pyaudio 0.2.11 with python 3.7 in anaconda. This isn't to contradict the fact that it isn't yet supported, but it is possible to have it running. –  Aug 24 '19 at 21:40
  • yes it works. just download the proper .whl from https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio then install it .then here you go ! – Fatihd Dec 25 '19 at 08:10
1

Download the binary installer for Windows and just install the PyAudio package with no nonsense.

PyAudio is built on top of portaudio library and you require portaudio to be there. The binary installer comes with precompiled version of portaudio as a dynamically linked library and there is no need for hunting and compiling the source.

PyAudio is a great library, enjoy working with it.

Dalen
  • 4,128
  • 1
  • 17
  • 35
  • He needs lower version of Python. Binaries of portAudio are pre packaged already. – Dinko Pehar Aug 24 '19 at 14:30
  • @DinkoPehar : That too, but it is irrelevant for my answer as binary installers for non-supported Python versions do not exist. As for portaudio's prepackaged binaries, it is obvious that the error occurs when setup.py tries to compile portaudio from the source. Where is then that precompiled version in this scenario? If there is one included, then the installation would pass and Python would complain afterwards, upon importing the module. – Dalen Aug 24 '19 at 15:12
  • It's lot easier for him to install it via `pip` than to compile from source. – Dinko Pehar Aug 24 '19 at 16:52
  • 1
    @DinkoPehar : pip downloads the package (source version) and then runs its setup.py, which,, in case of PyAudio, compiles it from source. Usually it does not check whether the Python version is compatible or not. A binary installer, if you are not aware, is an *.exe or *.msi installer requiring few clicks on the stupid Next button. – Dalen Aug 24 '19 at 17:01
  • I didn't understand what you were referring to at the beginning. I thought you meant for him to download precompiled version of portaudio then to install somehow pyAudio, but your were referring to http://people.csail.mit.edu/hubert/pyaudio/packages/ `.exe` files listed there if I'm not mistaken. I'll append your answer to mine if that's the case. – Dinko Pehar Aug 24 '19 at 17:24
  • @DinkoPehar : Yep! In the beginning PyAudio had official releases of binary installers (if I remember correctly), but then they were discontinued. This secondary source should be safe though. – Dalen Aug 24 '19 at 17:31
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/198423/discussion-between-dinko-pehar-and-dalen). – Dinko Pehar Aug 24 '19 at 17:33
1
pip install pipwin

pipwin install pyaudio

Try these commands in prompt. It does not require any manual downloads or searches etc. pipwin is a complementary tool for pip on Windows. It is capable of installing unofficial python package binaries for Windows provided by Christoph Gohlke

helvete
  • 2,455
  • 13
  • 33
  • 37
0

the key info in the error message is "Cannot open include file: 'portaudio.h': No such file or directory"

so you should google it, and you will find it have an answer in stackoverflow: https://stackoverflow.com/a/52191687/5232323

the current version PyAudio 0.2.11 is not supported for Python 3.7

Dalen
  • 4,128
  • 1
  • 17
  • 35
tinyhare
  • 2,271
  • 21
  • 25