Python,Flask,Gunicorn错误:无法识别的参数

问题描述:

我使用Python和Flask运行我的应用app.py。我试图将它部署到Heroku,并且我遵循了this tutorial中的步骤,包括制作Procfile和requirements.txt。但是,每当我跑heroku local,我得到以下错误:Python,Flask,Gunicorn错误:无法识别的参数

web.1 | [2015-09-26 17:36:32 -0400] [19422] [INFO] Starting gunicorn 19.3.0 
web.1 | [2015-09-26 17:36:32 -0400] [19422] [INFO] Listening at: http://0.0.0.0:5000 (19422) 
web.1 | [2015-09-26 17:36:32 -0400] [19422] [INFO] Using worker: sync 
web.1 | [2015-09-26 17:36:32 -0400] [19425] [INFO] Booting worker with pid: 19425 
web.1 | usage: gunicorn [-h] [--auth_host_name AUTH_HOST_NAME] 
web.1 | gunicorn: error: unrecognized arguments: app:app 
web.1 | [2015-09-26 17:36:32 -0400] [19425] [INFO] Worker exiting (pid: 19425) 

我以前在Heroku上部署的应用程序成功,但从未已经得到了这个错误。我的Procfile只是一行:web: gunicorn app:app

有谁能告诉我如何解决这个问题吗?

UPDATE: 修改了一些我的代码,现在当我运行heroku local,它精致运行:

web.1 | [2015-09-28 18:52:13 -0400] [70650] [INFO] Starting gunicorn 19.3.0 
web.1 | [2015-09-28 18:52:13 -0400] [70650] [INFO] Listening at: http://0.0.0.0:5000 (70650) 
web.1 | [2015-09-28 18:52:13 -0400] [70650] [INFO] Using worker: sync 
web.1 | [2015-09-28 18:52:13 -0400] [70653] [INFO] Booting worker with pid: 70653 

然而,当我部署我的Heroku上的应用程序,我得到一个应用程序错误,当我检查日志,我看到与以前一样的错误:

2015-09-28T22:50:54.775077+00:00 app[web.1]: 2015-09-28 22:50:54 [3] [INFO] Starting gunicorn 18.0 
2015-09-28T22:50:54.776176+00:00 app[web.1]: 2015-09-28 22:50:54 [3] [INFO] Using worker: sync 
2015-09-28T22:50:54.776052+00:00 app[web.1]: 2015-09-28 22:50:54 [3] [INFO] Listening at: http://0.0.0.0:24995 (3) 
2015-09-28T22:50:54.786067+00:00 app[web.1]: 2015-09-28 22:50:54 [9] [INFO] Booting worker with pid: 9 
2015-09-28T22:50:56.004336+00:00 heroku[web.1]: State changed from starting to up 
2015-09-28T22:51:42.659042+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=GET path="/" host=bobawithjames.herokuapp.com request_id=1afab4c0-484e-456b-be05-3086ee0711cd fwd="160.39.250.29" dyno=web.1 connect=1ms service=39ms status=503 bytes=0 
2015-09-28T22:51:42.604331+00:00 app[web.1]:     [--noauth_local_webserver] 
2015-09-28T22:51:42.604323+00:00 app[web.1]: usage: gunicorn [-h] [--auth_host_name AUTH_HOST_NAME] 
2015-09-28T22:51:42.604335+00:00 app[web.1]:     [--auth_host_port [AUTH_HOST_PORT [AUTH_HOST_PORT ...]]] 
2015-09-28T22:51:42.633611+00:00 app[web.1]: gunicorn: error: unrecognized arguments: hello:app 

任何人都知道现在发生了什么?

+0

尝试将您的文件重命名为'main.py'并将Procfile更改为:'web:gunicorn main:app' – ahmed

+0

@ahmed我试过并得到相同的错误。还有其他建议吗? – frogbandit

+0

我有同样的问题 - 任何人有修复? – crarho

我设法解决我的问题,建议@euxneks提出,以及一些搞乱谷歌OAuth 2.0。

实质上,我一直在使用的教程Python Quickstart for Google Calendar API正在使用​​来获取凭证的标志。然而,这也被称为tools.run,这已被弃用。相反,我决定遵循一个different, more up-to-date tutorial,它引导您使用Python Web App使用OAuth 2.0。