2

While I'm trying to run pip install PyAudio, I'm seeing the following error:

  Using cached https://files.pythonhosted.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gz
Building wheels for collected packages: PyAudio
  Building wheel for PyAudio (setup.py) ... error
  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: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-o_0h_bmo/PyAudio/setup.py'"'"'; __file__='"'"'/tmp/pip-install-o_0h_bmo/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 /tmp/pip-record-8_ovxdkm/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.
Redowan Delowar
  • 1,088
  • 8
  • 22

2 Answers2

2

You just need to remove libav-tools from apt install and run this command again.

!apt install libasound2-dev portaudio19-dev libportaudio2 libportaudiocpp0 ffmpeg

and then

!pip install PyAudio

You will be able to install it.

2

Assuming that you're running the default Python (currently, version 3.7.10) on Colab. In that case, PyAudio is an old and possibly unmaintained package and there is no wheel for Python 3.7.

The official documentation says:

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.

There are two ways you can solve this—

  • Going with a different package that does similar things. Checkout Python Sound Device.

  • Downgrade your Colab environment to Python 3.6. Check out the instructions here.

If I were you, I would go with the first option as you should be using the newer Python version anyway. Also, subjectively, Python Sound Device has the better API.

Redowan Delowar
  • 1,088
  • 8
  • 22