如何解决无法在 google colab 中安装 pyaudio
当我尝试运行 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.
解决方法
您只需要从 apt install 中删除 libav-tools
并再次运行此命令。
!apt install libasound2-dev portaudio19-dev libportaudio2 libportaudiocpp0 ffmpeg
然后
!pip install PyAudio
您将能够安装它。
,假设您在 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。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。