在Heroku上运行python flask应用程序失败
我有一个python web应用程序,我可以使用此命令在本地计算机上成功运行在Heroku上运行python flask应用程序失败,python,heroku,Python,Heroku,我有一个python web应用程序,我可以使用此命令在本地计算机上成功运行 python run.py 我已经成功地将代码部署到Heroku,但当我转到我的应用程序URL时,我会收到以下错误消息: Application error. An error occurred in the application and your page could not be served. If you are the application owner, check your logs for deta
python run.py
我已经成功地将代码部署到Heroku,但当我转到我的应用程序URL时,我会收到以下错误消息:
Application error. An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command
heroku logs --tail
看看对数尾的收益率
heroku logs --tail ✘ 2
›错误:缺少所需的标志:
›-a,--app要对其运行命令
我的proc文件包含
web: python --app monte-carlo-retirement run.py
monte carlo retirement是我应用程序的名称你把两件事混为一谈了 有关缺少
-a
或-app
参数的错误与有关。不要只是heroku日志--tail
,而是尝试heroku日志--app=montecarlo retirement--tail
。这将为您提供有用的日志输出
另见和
您的Procfile
不需要该参数。您将代码部署到一个特定的应用程序,因此不会混淆它应用于哪个应用程序。此外,您将该参数赋给了python
,在这里它是没有意义的
将其从程序文件中取出:
web: python run.py
然后提交并重新部署
现在,您还没有向我们展示您的run.py
中包含的内容,但在生产环境中运行它将是一种奇怪的方式。一种更常见的方法是使用类似的方法
本地安装并将其添加到requirements.txt
(如果您使用的是pip
)或Pipfile
/Pipfile.lock
(如果您使用的是Pipenv)。然后再次将Procfile
修改为
web: gunicorn run:app
其中app
是run.py
中烧瓶对象的名称,您的所有导入是否都在requirement txt中?是。我的requirement.txt如下所示:SQLAlchemy==1.3.19 alembic==1.4.3 Flask==1.1.2 WTForms==2.3.3 Pizz==7.2.0 numpy==1.19.2 pandas==1.1.2 python dateutil==2.8.1 DateTime==4.3 ItsDanger==1.1.1.0 matplotlib==3.1错误消息似乎暗示我的Procfile有问题,这是我第一次尝试使用Heroku谢谢克里斯。我是网络开发的新手。你的回答让我“松了一口气”。