简体   繁体   English

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

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

Trying to install pyaudio on Google Colab but got an error "ERROR: Failed building wheel for pyaudio".尝试在 Google Colab 上安装 pyaudio 但出现错误“错误:pyaudio 的构建轮失败”。

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

I got this error:我收到此错误:

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/

I just need to remove libav-tools from apt install and run this command again.我只需要从apt install删除libav-tools并再次运行此命令。

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

Now pyaudio is installed successfully.现在pyaudio安装成功。

I was pleased to follow these step after I found out Python installation on my Ubuntu 20.04 machine.在我的 Ubuntu 20.04 机器上发现 Python 安装后,我很高兴遵循这些步骤。 Some libraries which were easily install-able on Ubuntu 18.04 are not getting installed on 20.04 for that some dependency issue can occur.一些可以轻松安装在 Ubuntu 18.04 上的库没有安装在 20.04 上,因为可能会出现一些依赖性问题。 After a proper Python installation, I could avoid any pyaudio issue.在正确安装 Python 之后,我可以避免任何 pyaudio 问题。

Tested only on Ubuntu machine:仅在 Ubuntu 机器上测试:

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

I was please to follow these step after I found out Python installation on my Ubuntu 20.04 machine.在我的 Ubuntu 20.04 机器上发现 Python 安装后,我很高兴遵循这些步骤。 Some libraries which were easily install-able on Ubuntu 18.04 are not getting installed on 20.04 for that some dependency issue can occur.一些可以轻松安装在 Ubuntu 18.04 上的库没有安装在 20.04 上,因为可能会出现一些依赖性问题。 After a proper Python installation I could avoid avoid any PyAudio issue.在正确安装 Python 之后,我可以避免任何 PyAudio 问题。

Tested only on Ubuntu machine:仅在 Ubuntu 机器上测试:

1- sudo apt-get update 1- sudo apt-get 更新

2- sudo apt-get install -y build-essential check install 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 3- sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

I will be installing it from /usr/src but you can use any location of your choice:我将从 /usr/src 安装它,但您可以使用您选择的任何位置:

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

**Extracting downloaded package:**

5- sudo tar xzf Python-3.6.9.tgz 5- 须藤 tar xzf Python-3.6.9.tgz

  **Compiling Source:**

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

  **Building python:**

8- sudo make altinstall 8- sudo make altinstall

 **Verify Installation:**

9- python3.6 --version 9- python3.6 --version

Upgrading pip (optional): 10 - Install dependency for pip sudo apt-get install -y python3-distutils python3-testresources升级 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 11- cd ~/ wget https://bootstrap.pypa.io/get-pip.py sudo python3.6 get-pip.py

12- If you like to use Alias? 12-如果您喜欢使用别名?

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

** Using update-alternatives** ** 使用更新替代品**
Check your python path for adding it to update-alternatives config:检查您的 python 路径以将其添加到 update-alternatives 配置:

13 - which python3.6 13 - 其中python3.6

My path was /usr/local/bin/python3.6 Adding path to update-alternatives config:我的路径是 /usr/local/bin/python3.6 将路径添加到 update-alternatives 配置:

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

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

16- pip install pyaudio 16-pip 安装 pyaudio

###Lycka till ### ###Lycka直到###

Goes to this site:去这个网站:

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

And search (by pressing ctrl+f) for pyaudio .并搜索(通过按 ctrl+f) pyaudio Then you download your whl file of your python suitable version and open windows poweshell in the downloads folder where you downloaded the file.然后下载 python 合适版本的 whl 文件,并在下载文件的下载文件夹中打开 windows poweshell。 After that, open poweshell, type pip, install filename and then hit enter.之后,打开 poweshell,输入 pip,安装文件名,然后回车。 Installed easily.安装方便。

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

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