Flask python应用程序在heroku上崩溃

时间:2017-06-07 04:31:06

标签: python git heroku flask

我尝试将我的代码直接推送到Heroku进行托管,但是我遇到了很多错误。现在,我所做的是在Github上托管代码,然后将git repo与Heroku链接。现在,Heroku应用程序已成功创建,但现在它没有运行,因为它崩溃时出现错误代码H10和状态503.我的app.py代码是;

from flask import Flask

app = Flask(__name__)


@app.route('/')
def hello():
    return "Hello World"

if __name__ == '__main__':
    app.run(debug=True)

来自Heroku

Application Logs:

2017-06-07T04:06:26.163984+00:00 heroku[web.1]: State changed from starting 
to crashed
2017-06-07T04:32:14.975648+00:00 heroku[web.1]: State changed from crashed 
to starting
2017-06-07T04:32:25.466677+00:00 heroku[web.1]: Starting process with 
command `gunicorn malicha:app --log-file=-`
2017-06-07T04:32:27.733743+00:00 heroku[web.1]: Process exited with status 
127
2017-06-07T04:32:27.646433+00:00 app[web.1]: bash: gunicorn: command not 
found
2017-06-07T04:32:27.750144+00:00 heroku[web.1]: State changed from starting 
to crashed
2017-06-07T05:23:25.211376+00:00 heroku[web.1]: State changed from crashed 
to starting
2017-06-07T05:23:36.977579+00:00 heroku[web.1]: Starting process with 
command `gunicorn malicha:app --log-file=-`
2017-06-07T05:23:39.121911+00:00 app[web.1]: bash: gunicorn: command not 
found
2017-06-07T05:23:39.208060+00:00 heroku[web.1]: State changed from starting 
to crashed
2017-06-07T05:23:39.193064+00:00 heroku[web.1]: Process exited with status 207 

我的requirements.txt

AppInst==2.1.5
Flask==0.12.2
Jinja2==2.9.6
MarkupSafe==1.0
Pillow==4.0.0
PyYAML==3.11
Pygments==2.1.3
Werkzeug==0.12.2
appdirs==1.4.3
apptools==4.4.0
argparse==1.4.0
attrs==15.2.0
backports-abc==0.5  
backports.shutil-get-terminal-size==1.0.0   
beautifulsoup4==4.4.1
bleach==1.5.0
boto==2.40.0
certifi==2017.4.17
chardet==3.0.3
click==6.7
colorama==0.3.9
colorthief==0.2.1
configobj==5.0.6
configparser==3.5.0
cycler==0.10.0  
decorator==4.0.9
dlib==19.4.0
docutils==0.13.1
ecdsa==0.13
encore==0.7.0
enstaller==4.8.12
entrypoints==0.2.2
enum34==1.1.6
envisage==4.6.0
esky==0.9.8  
feedparser==5.2.1
flake8==3.3.0
futures==3.0.3
gnureadline==6.3.3
gunicorn==19.7.1
hatcher==0.10.4
html5lib==0.999
humanize==0.5.1
idna==2.5
imutils==0.4.3
ipykernel==4.5.2
ipython==4.0.0
ipython-genutils==0.1.0 
ipywidgets==6.0.0
itsdangerous==0.24
jedi==0.10.2
jsonify==0.5
jsonschema==2.6.0
jupyter==1.0.0
jupyter-client==5.0.0   
jupyter-console==5.1.0  
jupyter-core==4.3.0 
keyring==10.3.3
lxml==3.8.0
matplotlib==2.0.2
mccabe==0.6.1
memory-profiler==0.43   
mistune==0.7.4
mpmath==0.19
nbconvert==5.2.1
nbformat==4.3.0
nose==1.3.7
notebook==4.4.1
numpy==1.12.1
okonomiyaki==0.16.10
olefile==0.44
opencv-python==3.2.0.7 
packaging==16.8
pandas==0.20.2
pandocfilters==1.4.1
path.py==10.3.1
pathlib2==2.2.1
pbr==3.0.1
pep8==1.7.0
pexpect==4.2.1
pickleshare==0.7.4
pip==9.0.1
plotly==2.0.9
ply==3.10
prompt-toolkit==1.0.13  
psutil==5.2.2
psycopg2==2.7.1
ptyprocess==0.5.1
pyasn1==0.2.3
pycodestyle==2.3.1
pycrypto==2.6.1
pyface==5.1.0
pyflakes==1.5.0
pyglet==1.1.4
pymongo==3.4.0
pyparsing==2.2.0
python-dateutil==2.6.0
pytz==2017.2
pyzmq==16.0.2
qtconsole==4.3.0
requests==2.17.3
rsa==3.4.2
scipy==0.19.0 
simplegeneric==0.8.1
singledispatch==3.4.0.3
six==1.10.0
stevedore==1.23.0
sympy==1.0
tabulate==0.7.7
terminado==0.6
testpath==0.3.1
tornado==4.5.1
traitlets==4.3.2
traits==4.6.0
traits-enaml==0.2.1
traitsui==5.1.0
tzlocal==1.4
urllib3==1.21.1
virtualenv==15.1.0
wcwidth==0.1.7
cmake==0.7.1

我的Procfile

    web: gunicorn malicha:app --log-file=-

构建日志

后的构建日志部分



-----> Found requirements.txt, installing dependencies using pip
DEPRECATION: --allow-all-external has been deprecated and will be removed in the future. Due to changes in the repository protocol, it no longer has any effect.
Collecting AppInst==2.1.5 (from -r requirements.txt (line 1))
  Downloading AppInst-2.1.5.tar.gz
Collecting Flask==0.12.2 (from -r requirements.txt (line 2))
  Downloading Flask-0.12.2-py2.py3-none-any.whl (83kB)
Collecting Jinja2==2.9.6 (from -r requirements.txt (line 3))
  Downloading Jinja2-2.9.6-py2.py3-none-any.whl (340kB)
Collecting MarkupSafe==1.0 (from -r requirements.txt (line 4))
  Downloading MarkupSafe-1.0.tar.gz
Collecting Pillow==4.0.0 (from -r requirements.txt (line 5))
  Downloading Pillow-4.0.0-cp27-cp27m-manylinux1_x86_64.whl (5.6MB)
Collecting PyYAML==3.11 (from -r requirements.txt (line 6))
  Downloading PyYAML-3.11.zip (371kB)
Collecting Pygments==2.1.3 (from -r requirements.txt (line 7))
  Downloading Pygments-2.1.3-py2.py3-none-any.whl (755kB)
Collecting Werkzeug==0.12.2 (from -r requirements.txt (line 8))
  Downloading Werkzeug-0.12.2-py2.py3-none-any.whl (312kB)
Requirement already satisfied: appdirs==1.4.3 in ./.heroku/vendor/lib/python2.7/site-packages (from -r requirements.txt (line 9))
Collecting apptools==4.4.0 (from -r requirements.txt (line 10))
  Downloading apptools-4.4.0.zip (490kB)
Collecting argparse==1.4.0 (from -r requirements.txt (line 11))
  Downloading argparse-1.4.0-py2.py3-none-any.whl
Collecting attrs==15.2.0 (from -r requirements.txt (line 12))
  Downloading attrs-15.2.0-py2.py3-none-any.whl
Collecting backports-abc==0.5 (from -r requirements.txt (line 13))
  Downloading backports_abc-0.5-py2.py3-none-any.whl
Collecting backports.shutil-get-terminal-size==1.0.0 (from -r requirements.txt (line 14))
  Downloading backports.shutil_get_terminal_size-1.0.0-py2.py3-none-any.whl
Collecting beautifulsoup4==4.4.1 (from -r requirements.txt (line 15))
  Downloading beautifulsoup4-4.4.1-py2-none-any.whl (81kB)
Collecting bleach==1.5.0 (from -r requirements.txt (line 16))
  Downloading bleach-1.5.0-py2.py3-none-any.whl
Collecting boto==2.40.0 (from -r requirements.txt (line 17))
  Downloading boto-2.40.0-py2.py3-none-any.whl (1.3MB)
Collecting certifi==2017.4.17 (from -r requirements.txt (line 18))
  Downloading certifi-2017.4.17-py2.py3-none-any.whl (375kB)
Collecting chardet==3.0.3 (from -r requirements.txt (line 19))
  Downloading chardet-3.0.3-py2.py3-none-any.whl (133kB)
Collecting click==6.7 (from -r requirements.txt (line 20))
  Downloading click-6.7-py2.py3-none-any.whl (71kB)
Collecting colorama==0.3.9 (from -r requirements.txt (line 21))
  Downloading colorama-0.3.9-py2.py3-none-any.whl
Collecting colorthief==0.2.1 (from -r requirements.txt (line 22))
  Downloading colorthief-0.2.1-py2.py3-none-any.whl
Collecting configobj==5.0.6 (from -r requirements.txt (line 23))
  Downloading configobj-5.0.6.tar.gz
Collecting configparser==3.5.0 (from -r requirements.txt (line 24))
  Downloading configparser-3.5.0.tar.gz
Collecting cycler==0.10.0 (from -r requirements.txt (line 25))
  Downloading cycler-0.10.0-py2.py3-none-any.whl
Collecting decorator==4.0.9 (from -r requirements.txt (line 26))
  Downloading decorator-4.0.9-py2.py3-none-any.whl
Requirement already satisfied: dlib==19.4.0 in ./.heroku/vendor/lib/python2.7/site-packages (from -r requirements.txt (line 27))
Collecting docutils==0.13.1 (from -r requirements.txt (line 28))
  Downloading docutils-0.13.1-py2-none-any.whl (537kB)
Collecting ecdsa==0.13 (from -r requirements.txt (line 29))
  Downloading ecdsa-0.13-py2.py3-none-any.whl (86kB)
Collecting encore==0.7.0 (from -r requirements.txt (line 30))
  Downloading encore-0.7.0.tar.gz (122kB)
Collecting enstaller==4.8.12 (from -r requirements.txt (line 31))
  Downloading enstaller-4.8.12.tar.gz (905kB)
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-PRtgXg/enstaller/setup.py", line 146, in <module>
        write_version_py()
      File "/tmp/pip-build-PRtgXg/enstaller/setup.py", line 88, in write_version_py
        raise ImportError("Unable to import git_revision. Try removing "
    ImportError: Unable to import git_revision. Try removing enstaller/_version.py and the build directory before building.
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-PRtgXg/enstaller/
-----> Creating environment variables.
-----> Buildpack installed.
-----> Discovering process types
       Procfile declares types -> web
-----> Compressing...
       Done: 176.8M
-----> Launching...
       Released v26
       https://malicha.herokuapp.com/ deployed to Heroku
&#13;
&#13;
&#13;

构建时出现

错误
on inspecting the build log, I discovered an error while building :  Downloading enstaller-4.8.12.tar.gz (905kB)
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/pip-build-PRtgXg/enstaller/setup.py", line 146, in <module>
    write_version_py()
  File "/tmp/pip-build-PRtgXg/enstaller/setup.py", line 88, in write_version_py
    raise ImportError("Unable to import git_revision. Try removing "
ImportError: Unable to import git_revision. Try removing enstaller/_version.py and the build directory before building.

----------------------------------------

命令&#34; python setup.py egg_info&#34;在/ tmp / pip-build-PRtgXg / enstaller /

中失败,错误代码为1

1 个答案:

答案 0 :(得分:0)

我只需从

编辑我的Procfile即可解决问题
web: gunicorn app:app --log-file=-

web: gunicorn src.app:app --log-file=-