无法将Python 3 Flask应用程序推送到Heroku上

时间:2015-07-05 11:06:27

标签: python heroku flask

我有一个简单直接的Python Flask应用程序。我试图在Heroku上部署它。我正在使用Python 3运行时。我可以使用foreman start在本地运行它,但它无法在Heroku上构建并拒绝它。

这是日志:

Counting objects: 29, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (25/25), done.
Writing objects: 100% (29/29), 6.08 KiB | 0 bytes/s, done.
Total 29 (delta 11), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Python app detected
remote: -----> Installing runtime (python-3.4.3)
remote: -----> Installing dependencies with pip
remote:        Collecting Flask==0.9 (from -r requirements.txt (line 1))
remote:          Downloading Flask-0.9.tar.gz (481kB)
remote:            Complete output from command python setup.py egg_info:
remote:            Traceback (most recent call last):
remote:              File "<string>", line 20, in <module>
remote:              File "/tmp/pip-build-r95ud3px/Flask/setup.py", line 62
remote:                print "Audit requires PyFlakes installed in your system."
remote:                                                                        ^
remote:            SyntaxError: Missing parentheses in call to 'print'
remote:            
remote:            ----------------------------------------
remote: Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-r95ud3px/Flask
remote: 
remote:  !     Push rejected, failed to compile Python app
remote: 
remote: Verifying deploy....
remote: 
remote: !   Push rejected to xxxxxxxxxxxxxxxxxx.
remote: 
To https://git.heroku.com/xxxxxxxxxxxxxxxxxx.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/xxxxxxxxxxxxxxxxxx.git'

那么,我究竟做错了什么?

修改

文件:Procfile

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

app.py是主应用程序。

文件:requirements.txt

Flask==0.9
Jinja2==2.6
Werkzeug==0.8.3
gunicorn==0.17.2

文件:runtime.txt

python-3.4.3

1 个答案:

答案 0 :(得分:7)

Flask版本 0.9 不支持python 3,因为它读入了docs

  

Flask 0.10和Werkzeug 0.9是第一个推出的版本   Python 3支持。

所以你应该使用 Flask 0.10.1 。修改 requirements.txt ,如下所示:

Flask==0.10.1
Werkzeug==0.10.4