本文介绍了无法在GAE灵活环境(Python)上安装PyAudio的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有很多问题让这个瓶子后退。除了识别从前端传送的音频的逻辑之外,它是非常标准的东西。为此,我加入了PyDejaVu。



其中一个依赖关系(PyAudio)没有正确构建。



以下是一些日志:

 步骤1:#includeportaudio.h
步骤1:^
步骤1:编译终止。
步骤1:错误:命令'x86_64-linux-gnu-gcc'失败,退出状态1
步骤#1:PyAudio的构建轮失败

 命令/ env / bin / python -u -cimport setuptools,tokenize; __ file __ ='/ tmp / pip-build-arQ8b7 / PyAudio / setup.py'; f = getattr(tokenize,'open',open)(__ file __); code = f.read ().replace('\r\\\
','\\\
'); f.close(); exec(compile(code,__file__,'exec'))install --record / tmp / pip- 4yefCE-record / install-record.txt --single-version-external-managed --compile --install-headers /env/include/site/python2.7/PyAudiofailed with error code 1 in / tmp / pip- build-arQ8b7 / PyAudio /
步骤1:命令'/ bin / sh -c pip install -r requirements.txt'返回一个非零代码:1
完成步骤1
错误
错误:构建步骤1gcr.io/cloud-builders/docker@sha256:0d9f13d75152530e2ee49bf3a3be3d6198b946f7315b3961994355a7aaee2925失败:退出状态1
步骤1:
- ----------

requirements.txt

  PyAudio == 0.2.9 
PyDejaVu == 0.1.3
werkzeug == 0.14.1
flask-cors = = 2.1.2
flask-login == 0.3.2
flask-oauthlib == 0.9.2
flask-restful == 0.3.5
flask-wtf == 0.12
flask == 0.12.2
flask-sqlalchemy == 0.9
numpy == 1.13.3
gunicorn == 19.7.1

我跟踪了这​​些错误,显然我必须通过apt-get安装端口音频,但显然这是不可能的。



任何帮助都会被赞赏!

解决方案

由于App Engine flex基于docker,从Dockerfile安装依赖关系。在这种情况下,您必须自定义App Engine Python 以添加所有库PyAudio可能需要。你可以看看一些包含PyAudio的Dockerfiles & 。



我可以去通过在Dockerfile中添加以下依赖项和库来解决错误:

  RUN apt-get update&& apt-get install -y \ 
vim \
curl \
wget \
git \
make \
netcat \
python \
python2.7-dev \
g ++ \
bzip2 \
binutils
######### ################################################## ####################
RUN apt-get install -y portaudio19-dev libopenblas -base libopenblas-dev pkg-config git-core cmake python-dev liblalas-dev libatlas-base-dev libblitz0-dev libboost-all-dev libhdf5-serial-dev libqt4-dev libsvm-dev libvlfeat-dev python-nose python -setuptools python-imaging build-essential libmatio-dev python-sphinx python- matplotlib python-scipy
#附加依赖项
运行apt-get install -y \
libasound2 \
libasound-dev \
libssl-dev

RUN pip install pyaudio


So I am having quite a few issues getting this flask backend up. It is pretty standard stuff apart from some logic that recognizes audio delivered from the frontend. To do this, I incorporate PyDejaVu.

One of the dependencies(PyAudio) is not building correctly. Everything else is good to go.

Here are some logs:

Step #1:    #include "portaudio.h"
Step #1:                          ^
Step #1:   compilation terminated.
Step #1:   error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Step #1:   Failed building wheel for PyAudio

and

Command "/env/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-arQ8b7/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-4yefCE-record/install-record.txt --single-version-externally-managed --compile --install-headers /env/include/site/python2.7/PyAudio" failed with error code 1 in /tmp/pip-build-arQ8b7/PyAudio/
Step #1: The command '/bin/sh -c pip install -r requirements.txt' returned a non-zero code: 1
Finished Step #1
ERROR
ERROR: build step 1 "gcr.io/cloud-builders/docker@sha256:0d9f13d75152530e2ee49bf3a3be3d6198b946f7315b3961994355a7aaee2925" failed: exit status 1
Step #1:
------------

requirements.txt

PyAudio==0.2.9
PyDejaVu==0.1.3
werkzeug==0.14.1
flask-cors==2.1.2
flask-login==0.3.2
flask-oauthlib==0.9.2
flask-restful==0.3.5
flask-wtf==0.12
flask==0.12.2
flask-sqlalchemy==0.9
numpy==1.13.3
gunicorn==19.7.1

I followed the errors and apparently I have to install port-audio via apt-get but that obviously is not possible.

Any help is appreciated!

解决方案

Since App Engine flex is based on docker you'll have to install dependencies from the Dockerfile. In this case you'd have to customize the App Engine Python Dockerfile to add all the libraries PyAudio might need. You could look at some Dockerfiles containing PyAudio Sample1 & Sample2.

I could go over the error by adding the following dependencies and libraries in the Dockerfile:

RUN apt-get update && apt-get install -y \
        vim \
        curl \
        wget \
        git \
        make \
        netcat \
        python \
        python2.7-dev \
        g++ \
        bzip2 \
        binutils
###############################################################################
RUN apt-get install -y portaudio19-dev libopenblas-base libopenblas-dev pkg-config git-core cmake python-dev liblapack-dev libatlas-base-dev libblitz0-dev libboost-all-dev libhdf5-serial-dev libqt4-dev libsvm-dev libvlfeat-dev  python-nose python-setuptools python-imaging build-essential libmatio-dev python-sphinx python-matplotlib python-scipy
# additional dependencies
RUN apt-get install -y \
        libasound2 \
        libasound-dev \
        libssl-dev

RUN pip install pyaudio

这篇关于无法在GAE灵活环境(Python)上安装PyAudio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 11:13