簡體   English   中英

無法將 Flask 應用程序推送到 Heroku。 袖珍獅身人面像

[英]Failing to push a Flask app to Heroku. pocketsphinx

我正在嘗試將 Flask 應用程序部署到 heroku。 嘗試安裝pocketsphinx時似乎失敗了。

該項目在我的本地機器上運行良好,但無法部署。

我怎么能解決這個問題?

Enumerating objects: 659, done.
Counting objects: 100% (659/659), done.
Delta compression using up to 4 threads
Compressing objects: 100% (615/615), done.
Writing objects: 100% (659/659), 58.57 MiB | 329.00 KiB/s, done.
Total 659 (delta 69), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Building on the Heroku-20 stack
remote: -----> Determining which buildpack to use for this app
remote: -----> Python app detected
remote: -----> Using Python version specified in runtime.txt
remote:  !     Python has released a security update! Please consider upgrading to python-3.8.10
remote:        Learn More: https://devcenter.heroku.com/articles/python-runtimes
remote: -----> Installing python-3.8.5
remote: -----> Installing pip 20.2.4, setuptools 47.1.1 and wheel 0.36.2
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip
remote:        Collecting blinker==1.4
remote:          Downloading blinker-1.4.tar.gz (111 kB)
remote:        Collecting click==8.0.1
remote:          Downloading click-8.0.1-py3-none-any.whl (97 kB)
remote:        Collecting Flask==2.0.1
remote:          Downloading Flask-2.0.1-py3-none-any.whl (94 kB)
remote:        Collecting flask-requests==0.0.14
remote:          Downloading flask_requests-0.0.14.tar.gz (2.0 kB)
remote:        Collecting gunicorn==20.1.0
remote:          Downloading gunicorn-20.1.0-py3-none-any.whl (79 kB)
remote:        Collecting itsdangerous==2.0.1
remote:          Downloading itsdangerous-2.0.1-py3-none-any.whl (18 kB)
remote:        Collecting Jinja2==3.0.1
remote:          Downloading Jinja2-3.0.1-py3-none-any.whl (133 kB)
remote:        Collecting MarkupSafe==2.0.1
remote:          Downloading MarkupSafe-2.0.1-cp38-cp38-manylinux2010_x86_64.whl (30 kB)
remote:        Collecting pampy==0.3.0
remote:          Downloading pampy-0.3.0-py3-none-any.whl (17 kB)
remote:        Collecting pocketsphinx==0.1.15
remote:          Downloading pocketsphinx-0.1.15.tar.gz (29.1 MB)
remote:        Collecting PyAudio==0.2.11
remote:          Downloading PyAudio-0.2.11.tar.gz (37 kB)
remote:        Collecting SpeechRecognition==3.8.1
remote:          Downloading SpeechRecognition-3.8.1-py2.py3-none-any.whl (32.8 MB)
remote:        Collecting Werkzeug==2.0.1
remote:          Downloading Werkzeug-2.0.1-py3-none-any.whl (288 kB)
remote:        Building wheels for collected packages: blinker, flask-requests, pocketsphinx, PyAudio
remote:          Building wheel for blinker (setup.py): started
remote:          Building wheel for blinker (setup.py): finished with status 'done'
remote:          Created wheel for blinker: filename=blinker-1.4-py3-none-any.whl size=13451 sha256=15507a064de16ed40eb2d9b3dee91a100290bd99a6f4ea39ca7fd1b86226bec8
remote:          Stored in directory: /tmp/pip-ephem-wheel-cache-fhg6_ns3/wheels/b7/a5/68/fe632054a5eadd531c7a49d740c50eb6adfbeca822b4eab8d4
remote:          Building wheel for flask-requests (setup.py): started
remote:          Building wheel for flask-requests (setup.py): finished with status 'done'
remote:          Created wheel for flask-requests: filename=flask_requests-0.0.14-py3-none-any.whl size=2414 sha256=74d09e95b3350728bc972941620ee5dd7d56d158c372b07e10b51ed121abbd5f
remote:          Stored in directory: /tmp/pip-ephem-wheel-cache-fhg6_ns3/wheels/c4/c9/a7/aaeb7dad02f88405532951bebd7901c02dc11059e0b331a060
remote:          Building wheel for pocketsphinx (setup.py): started
remote:          Building wheel for pocketsphinx (setup.py): finished with status 'error'
remote:          ERROR: Command errored out with exit status 1:
remote:           command: /app/.heroku/python/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-7ik6237u/pocketsphinx/setup.py'"'"'; __file__='"'"'/tmp/pip-install-7ik6237u/pocketsphinx/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-n13un_3i
remote:               cwd: /tmp/pip-install-7ik6237u/pocketsphinx/
remote:          Complete output (7 lines):
remote:          running bdist_wheel
remote:          running build_ext
remote:          building 'sphinxbase._sphinxbase' extension
remote:          swigging deps/sphinxbase/swig/sphinxbase.i to deps/sphinxbase/swig/sphinxbase_wrap.c
remote:          swig -python -modern -threads -Ideps/sphinxbase/include -Ideps/sphinxbase/include/sphinxbase -Ideps/sphinxbase/include/android -Ideps/sphinxbase/swig -outdir sphinxbase -o deps/sphinxbase/swig/sphinxbase_wrap.c deps/sphinxbase/swig/sphinxbase.i
remote:          unable to execute 'swig': Permission denied
remote:          error: command 'swig' failed with exit status 1
remote:          ----------------------------------------
remote:          ERROR: Failed building wheel for pocketsphinx
remote:          Running setup.py clean for pocketsphinx
remote:          Building wheel for PyAudio (setup.py): started
remote:          Building wheel for PyAudio (setup.py): finished with status 'error'
remote:          ERROR: Command errored out with exit status 1:
remote:           command: /app/.heroku/python/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-7ik6237u/pyaudio/setup.py'"'"'; __file__='"'"'/tmp/pip-install-7ik6237u/pyaudio/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-a0cgqlw1
remote:               cwd: /tmp/pip-install-7ik6237u/pyaudio/
remote:          Complete output (16 lines):
remote:          running bdist_wheel
remote:          running build
remote:          running build_py
remote:          creating build
remote:          creating build/lib.linux-x86_64-3.8
remote:          copying src/pyaudio.py -> build/lib.linux-x86_64-3.8
remote:          running build_ext
remote:          building '_portaudio' extension
remote:          creating build/temp.linux-x86_64-3.8
remote:          creating build/temp.linux-x86_64-3.8/src
remote:          gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/app/.heroku/python/include/python3.8 -c src/_portaudiomodule.c -o build/temp.linux-x86_64-3.8/src/_portaudiomodule.o
remote:          src/_portaudiomodule.c:29:10: fatal error: portaudio.h: No such file or directory
remote:             29 | #include "portaudio.h"
remote:                |          ^~~~~~~~~~~~~
remote:          compilation terminated.
remote:          error: command 'gcc' failed with exit status 1
remote:          ----------------------------------------
remote:          ERROR: Failed building wheel for PyAudio
remote:          Running setup.py clean for PyAudio
remote:        Successfully built blinker flask-requests
remote:        Failed to build pocketsphinx PyAudio
remote:        Installing collected packages: blinker, click, MarkupSafe, Jinja2, itsdangerous, Werkzeug, Flask, pampy, flask-requests, gunicorn, pocketsphinx, PyAudio, SpeechRecognition
remote:            Running setup.py install for pocketsphinx: started
remote:            Running setup.py install for pocketsphinx: finished with status 'error'
remote:            ERROR: Command errored out with exit status 1:
remote:             command: /app/.heroku/python/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-7ik6237u/pocketsphinx/setup.py'"'"'; __file__='"'"'/tmp/pip-install-7ik6237u/pocketsphinx/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-xdfr6a6a/install-record.txt --single-version-externally-managed --compile --install-headers /app/.heroku/python/include/python3.8/pocketsphinx
remote:                 cwd: /tmp/pip-install-7ik6237u/pocketsphinx/
remote:            Complete output (7 lines):
remote:            running install
remote:            running build_ext
remote:            building 'sphinxbase._sphinxbase' extension
remote:            swigging deps/sphinxbase/swig/sphinxbase.i to deps/sphinxbase/swig/sphinxbase_wrap.c
remote:            swig -python -modern -threads -Ideps/sphinxbase/include -Ideps/sphinxbase/include/sphinxbase -Ideps/sphinxbase/include/android -Ideps/sphinxbase/swig -outdir sphinxbase -o deps/sphinxbase/swig/sphinxbase_wrap.c deps/sphinxbase/swig/sphinxbase.i
remote:            unable to execute 'swig': Permission denied
remote:            error: command 'swig' failed with exit status 1
remote:            ----------------------------------------
remote:        ERROR: Command errored out with exit status 1: /app/.heroku/python/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-7ik6237u/pocketsphinx/setup.py'"'"'; __file__='"'"'/tmp/pip-install-7ik6237u/pocketsphinx/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-xdfr6a6a/install-record.txt --single-version-externally-managed --compile --install-headers /app/.heroku/python/include/python3.8/pocketsphinx Check the logs for full command output.
remote:  !     Push rejected, failed to compile Python app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !   Push rejected to demo-sr-project.
remote: 
To https://git.heroku.com/demo-sr-project.git
 ! [remote rejected] master -> master (pre-receive hook declined)

我認為問題在於安裝pocketsphinx。 我在本地機器上運行heroku local web並且它運行,但我無法將它部署到 heroku。

要求網.txt

blinker==1.4
click==8.0.1
Flask==2.0.1
flask-requests==0.0.14
gunicorn==20.1.0
itsdangerous==2.0.1
Jinja2==3.0.1
MarkupSafe==2.0.1
pampy==0.3.0
pocketsphinx==0.1.15
PyAudio==0.2.11
SpeechRecognition==3.8.1
Werkzeug==2.0.1

檔案

web: gunicorn wsgi:app

運行時.txt

python-3.8.5

根據錯誤日志,您似乎需要在 heroku 機器上安裝 linux 依賴項。

PyAudio 文檔中,在 ubuntu 上,您需要安裝兩個包:python-pyaudio 和 python3-pyaudio。

它非常簡單,在你的 requirements.txt 旁邊添加一個名為“Aptfile”的新文件,並將 linux package 名稱添加到文件中。

因此,在您的情況下,該文件將僅具有:

python-pyaudio
python3-pyaudio

在里面。

然后 heroku 將在嘗試安裝您的應用程序之前安裝這些軟件包。

您可能需要在 heroku 中添加buildpack

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM