2015-07-05 103 views
1

我有一個簡單而直接的Python Flask應用程序。我試圖在Heroku上部署它。我正在使用Python 3運行時。我可以使用foreman start在本地運行它,但它無法在Heroku上構建並拒絕它。無法將Python 3 Flask應用推送到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 
+0

你需要使Heroku的使用正確的運行你的應用程序指定一個Python版本。用下面的代碼簡單地創建一個名爲** runtime.txt **的文件:'python-3.4.3'。在Git中提交你的更改,也可以選擇PUSH到Github。 – doru

+0

是的。我做了所有這些。我正在編輯我的問題,並添加所有相關的Heroku相關文件。 –

回答

6

瓶版本0.9沒有爲Python 3的支持,因爲它讀取的docs

Flask 0.10和Werkzeug 0.9是第一個引入01的版本Python 3支持。

所以你應該使用燒瓶0.10.1。修改您的requirements.txt如下:

Flask==0.10.1 
Werkzeug==0.10.4 
+0

謝謝你的幫助 –