繁体   English   中英

无法在 Google Colab 上安装 pyaudio,出现“错误:pyaudio 的构建轮失败”

[英]Failed installing pyaudio on Google Colab with "ERROR: Failed building wheel for pyaudio"

尝试在 Google Colab 上安装 pyaudio 但出现错误“错误:pyaudio 的构建轮失败”。

!apt install libasound2-dev portaudio19-dev libportaudio2 libportaudiocpp0 ffmpeg libav-tools
!pip install pyaudio

我收到此错误:

Collecting 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 "/usr/bin/python3 -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-000dzv_9/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-tvs_aja7/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-000dzv_9/pyaudio/

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

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

现在pyaudio安装成功。

在我的 Ubuntu 20.04 机器上发现 Python 安装后,我很高兴遵循这些步骤。 一些可以轻松安装在 Ubuntu 18.04 上的库没有安装在 20.04 上,因为可能会出现一些依赖性问题。 在正确安装 Python 之后,我可以避免任何 pyaudio 问题。

仅在 Ubuntu 机器上测试:

sudo apt-get update
sudo apt-get install -y build-essential checkinstall 

在我的 Ubuntu 20.04 机器上发现 Python 安装后,我很高兴遵循这些步骤。 一些可以轻松安装在 Ubuntu 18.04 上的库没有安装在 20.04 上,因为可能会出现一些依赖性问题。 在正确安装 Python 之后,我可以避免任何 PyAudio 问题。

仅在 Ubuntu 机器上测试:

1- sudo apt-get 更新

2- sudo apt-get install -y build-essential 检查安装

3- sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

我将从 /usr/src 安装它,但您可以使用您选择的任何位置:

4 - cd /usr/src sudo wget https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz

**Extracting downloaded package:**

5- 须藤 tar xzf Python-3.6.9.tgz

  **Compiling Source:**

6- cd Python-3.6.9 7- sudo ./configure --enable-optimizations

  **Building python:**

8- sudo make altinstall

 **Verify Installation:**

9- python3.6 --version

升级 pip(可选): 10 - 安装依赖 pip sudo apt-get install -y python3-distutils python3-testresources

 **Downloading get-pip.py and running:**

11- cd ~/ wget https://bootstrap.pypa.io/get-pip.py sudo python3.6 get-pip.py

12-如果您喜欢使用别名?

别名 py36=python3.6 别名 pip36=pip3.6

** 使用更新替代品**
检查您的 python 路径以将其添加到 update-alternatives 配置:

13 - 其中python3.6

我的路径是 /usr/local/bin/python3.6 将路径添加到 update-alternatives 配置:

14 - 须藤更新替代品 --install /usr/bin/python python /usr/local/bin/python3.6 0

15 - sudo apt install libasound2-dev portaudio19-dev libportaudio2 ibportaudiocpp0 ffmpeg

16-pip 安装 pyaudio

###Lycka直到###

去这个网站:

https://www.lfd.uci.edu/~gohlke/pythonlibs/

并搜索(通过按 ctrl+f) pyaudio 然后下载 python 合适版本的 whl 文件,并在下载文件的下载文件夹中打开 windows poweshell。 之后,打开 poweshell,输入 pip,安装文件名,然后回车。 安装方便。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM