为了账号安全,请及时绑定邮箱和手机立即绑定

我将我的 django web 应用程序部署到 heroku 并收到“应用程序错误”消息

我将我的 django web 应用程序部署到 heroku 并收到“应用程序错误”消息

大话西游666 2023-04-25 16:38:36
我已成功将我的 Django Web 应用程序部署到 Heroku,但收到了Application Error消息。但是,Web 应用程序在本地服务器中正常运行。这是我的应用程序日志:2020-08-04T03:32:15.540612+00:00 app[api]: Initial release by user rabby.jim999@gmail.com2020-08-04T03:32:15.540612+00:00 app[api]: Release v1 created by user rabby.jim999@gmail.com2020-08-04T03:32:15.857822+00:00 app[api]: Release v2 created by user rabby.jim999@gmail.com2020-08-04T03:32:15.857822+00:00 app[api]: Enable Logplex by user rabby.jim999@gmail.com2020-08-04T03:32:46.278800+00:00 app[api]: Set DISABLE_COLLECTSTATIC config vars by user rabby.jim999@gmail.com2020-08-04T03:32:46.278800+00:00 app[api]: Release v3 created by user rabby.jim999@gmail.com2020-08-04T03:34:06.000000+00:00 app[api]: Build started by user rabby.jim999@gmail.com2020-08-04T03:34:47.143606+00:00 app[api]: Attach DATABASE (@ref:postgresql-perpendicular-61467) by user rabby.jim999@gmail.com2020-08-04T03:34:47.143606+00:00 app[api]: Running release v4 commands by user rabby.jim999@gmail.com2020-08-04T03:34:47.154813+00:00 app[api]: Release v5 created by user rabby.jim999@gmail.com2020-08-04T03:34:47.154813+00:00 app[api]: @ref:postgresql-perpendicular-61467 completed provisioning, setting DATABASE_URL. by user rabby.jim999@gmail.com2020-08-04T03:34:47.474554+00:00 app[api]: Deploy e6fcf034 by user rabby.jim999@gmail.com2020-08-04T03:34:47.474554+00:00 app[api]: Release v6 created by user rabby.jim999@gmail.com2020-08-04T03:34:47.495253+00:00 app[api]: Scaled to web@1:Free by user rabby.jim999@gmail.com2020-08-04T03:34:53.033657+00:00 heroku[web.1]: Starting process with command `gunicorn newspaper_project.wsgi --log-file -`2020-08-04T03:34:55.434601+00:00 app[web.1]: bash: gunicorn: command not found2020-08-04T03:34:55.495150+00:00 heroku[web.1]: Process exited with status 1272020-08-04T03:34:55.534079+00:00 heroku[web.1]: State changed from starting to crashed2020-08-04T03:34:55.536481+00:00 heroku[web.1]: State changed from crashed to starting
查看完整描述

1 回答

?
森林海

TA贡献2011条经验 获得超2个赞

您将依赖项放在错误的位置。它们属于[packages]您的部分Pipfile,而不是[requires]部分。

通常,您应该很少需要手动编辑您的文件Pipfile,并且您永远不应该手动修改您的Pipfile.lock不要向您添加东西Pipfile,而是使用 来安装它们pipenv,例如通过运行

pipenv install gunicorn

Pipenv 会自动为你更新你的PipfilePipfile.lock

我建议您执行以下操作:

  1. Pipfile.lock本地删除

  2. 通过运行删除旧的 virtualenvpipenv --rm

  3. 移动除了python_version = "3.7"[requires][packages]

    • 考虑更改所有版本,"*"以便 Pipenv 可以免费更新版本

  4. 跑步pipenv install

  5. pipenv run如果您使用或从运行它,请确保应用程序在本地工作pipenv shell

  6. Pipfile.lock提交Pipenv 生成的新内容

  7. 部署

展望未来,我强烈建议您通过运行pipenv install而不是Pipfile手动修改或使用pip. 这样做的另一个好处是确保您的本地版本与 Heroku 上使用的版本相匹配。

runtime.txt哦,如果您使用的是 Pipenv,则不需要。所需的 Python 版本已在您的Pipfile.


查看完整回答
反对 回复 2023-04-25
  • 1 回答
  • 0 关注
  • 53 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信