简体   繁体   中英

Failing to push a Flask app to Heroku. pocketsphinx

I'm trying to deploy a Flask app to heroku. It happears that it fails while trying to install pocketsphinx.

The project works fine on my local machine but fails to deploy.

How could I fix that?

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)

I think the problem is with installing pocketsphinx. I run heroku local web on my local machine and it run, but I can't deploy it to heroku.

requiremnets.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

Procfile

web: gunicorn wsgi:app

runtime.txt

python-3.8.5

Based on the error log, it looks like you need to install a linux dependency on the heroku machine.

From the PyAudio docs , on ubuntu you need to install two packages: python-pyaudio and python3-pyaudio.

Its pretty simple, add a new file called "Aptfile" along side you requirements.txt, and add the linux package names to the file.

So in your case the file will simply have:

python-pyaudio
python3-pyaudio

in it.

Then heroku will install those packages before attempting to install your app.

You may need to add the buildpack in heroku.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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