【问题标题】:Cannot install pyaudio in google colab无法在 google colab 中安装 pyaudio
【发布时间】:2021-05-30 10:23:28
【问题描述】:

当我尝试运行 pip install PyAudio 时,我看到以下错误:

  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.

【问题讨论】:

    标签: python google-colaboratory pyaudio


    【解决方案1】:

    您只需从 apt install 中删除 libav-tools 并再次运行此命令。

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

    然后

    !pip install PyAudio

    您将能够安装它。

    【讨论】:

    • 在哪里可以删除 libav-tools?
    • 只需运行我共享的命令。您将能够安装@AbdunNoorPolok
    【解决方案2】:

    假设您在 Colab 上运行默认 Python(当前为 3.7.10 版)。在这种情况下,PyAudio 是一个旧的且可能未维护的包,并且没有适用于 Python 3.7 的轮子。

    官方documentation说:

    目前,有与官方发行版兼容的轮子 Python 2.7、3.4、3.5 和 3.6。对于这些版本,32 位和 64 位轮子可用。

    有两种方法可以解决这个问题——

    • 使用做类似事情的不同包。结帐Python Sound Device

    • 将您的 Colab 环境降级到 Python 3.6。查看说明here

    如果我是你,我会选择第一个选项,因为无论如何你都应该使用更新的 Python 版本。此外,主观上,Python Sound Device 具有更好的 API。

    【讨论】:

      猜你喜欢
      • 2019-06-04
      • 2019-01-02
      • 2019-08-28
      • 2021-04-12
      • 2021-06-23
      • 1970-01-01
      • 2020-08-21
      • 2020-03-27
      • 2020-06-09
      相关资源
      最近更新 更多