jugisoff
jugisoff

Reputation: 41

pyaudio error at the time of installation: subprocess-exited-with-error

Building wheel for pyaudio (setup.py) ... error
  error: subprocess-exited-with-error

Showing this error at the time of installation, I have updated pip and Python version but still got the same error. The full error:

(stt) F:\Python>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: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [53 lines of output]
      running bdist_wheel
      running build
      running build_py
      running build_ext
      building '_portaudio' extension
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\Jug\AppData\Local\Temp\pip-install-7dl19imj\pyaudio_618223816ae04aecb9311a803aa75afe\setup.py", line 106, in <module>
          setup(name='PyAudio',
        File "F:\Python\stt\lib\site-packages\setuptools\__init__.py", line 155, in setup
          return distutils.core.setup(**attrs)
        File "F:\Python\stt\lib\site-packages\setuptools\_distutils\core.py", line 148, in setup
          return run_commands(dist)
        File "F:\Python\stt\lib\site-packages\setuptools\_distutils\core.py", line 163, in run_commands
          dist.run_commands()
        File "F:\Python\stt\lib\site-packages\setuptools\_distutils\dist.py", line 967, in run_commands
          self.run_command(cmd)
        File "F:\Python\stt\lib\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
          cmd_obj.run()
        File "F:\Python\stt\lib\site-packages\wheel\bdist_wheel.py", line 299, in run
          self.run_command('build')
        File "F:\Python\stt\lib\site-packages\setuptools\_distutils\cmd.py", line 313, in run_command
          self.distribution.run_command(command)
        File "F:\Python\stt\lib\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
          cmd_obj.run()
        File "F:\Python\stt\lib\site-packages\setuptools\_distutils\command\build.py", line 135, in run
          self.run_command(cmd_name)
        File "F:\Python\stt\lib\site-packages\setuptools\_distutils\cmd.py", line 313, in run_command
          self.distribution.run_command(command)
        File "F:\Python\stt\lib\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
          cmd_obj.run()
        File "F:\Python\stt\lib\site-packages\setuptools\command\build_ext.py", line 79, in run
          _build_ext.run(self)
        File "F:\Python\stt\lib\site-packages\setuptools\_distutils\command\build_ext.py", line 339, in run
          self.build_extensions()
        File "F:\Python\stt\lib\site-packages\setuptools\_distutils\command\build_ext.py", line 448, in build_extensions
          self._build_extensions_serial()
        File "F:\Python\stt\lib\site-packages\setuptools\_distutils\command\build_ext.py", line 473, in _build_extensions_serial
          self.build_extension(ext)
        File "F:\Python\stt\lib\site-packages\setuptools\command\build_ext.py", line 202, in build_extension
          _build_ext.build_extension(self, ext)
        File "F:\Python\stt\lib\site-packages\setuptools\_distutils\command\build_ext.py", line 528, in build_extension
          objects = self.compiler.compile(sources,
        File "F:\Python\stt\lib\site-packages\setuptools\_distutils\_msvccompiler.py", line 327, in compile
          self.initialize()
        File "F:\Python\stt\lib\site-packages\setuptools\_distutils\_msvccompiler.py", line 224, in initialize
          vc_env = _get_vc_env(plat_spec)
        File "F:\Python\stt\lib\site-packages\setuptools\msvc.py", line 316, in msvc14_get_vc_env
          return _msvc14_get_vc_env(plat_spec)
        File "F:\Python\stt\lib\site-packages\setuptools\msvc.py", line 270, in _msvc14_get_vc_env
          raise distutils.errors.DistutilsPlatformError(
      setuptools._distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  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: subprocess-exited-with-error

  × Running setup.py install for pyaudio did not run successfully.
  │ exit code: 1
  ╰─> [8 lines of output]
      running install
      F:\Python\stt\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      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/
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> pyaudio

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

Upvotes: 4

Views: 35301

Answers (3)

user24970105
user24970105

Reputation: 11

According to the description in PyPI, use sudo apt install python3-pyaudio instead of pip.

Upvotes: 1

Saruni David
Saruni David

Reputation: 61

I resolved this by first executing this command:

sudo apt-get install portaudio19-dev

Then execute this command:

pip install PyAudio

Upvotes: 5

JoraSN
JoraSN

Reputation: 347

Get your appropriate .whl file from https://www.lfd.uci.edu/~gohlke/pythonlibs/ under pyaudio. You can find the appropriate .whl file by typing python in your cmd or terminal. You would get something like this:

Python 3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 18:58:18) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

Image description:

enter image description here

Note the python version and if python is 64 or 32 bit. Then get the .whl file appropriate for that version and machine. For me it would be this .whl file:

PyAudio‑0.2.11‑cp37‑cp37m‑win_amd64.whl

Next, go to the place where it was downloaded. For example, C:\Users\user\Downloads> then install .whl file using pip. For example in my case:

pip install PyAudio-0.2.11-cp37-cp37m-win_amd64.whl

or if the above doesn't work try:

Since pyAudio has portAudio as a dependency, you first have to install portaudio.

brew install portaudio

Then try: pip3 install pyAudio. If the problem persists after installing portAudio, you can specify the directory path where the compiler will be able to find the source programs (e.g: portaudio.h). Since the headers should be in the /usr/local/include directory:

pip install --global-option='build_ext' --global-option='-I/usr/local/include' --global-option='-L/usr/local/lib' pyaudio

Upvotes: 6

Related Questions