首页 > 解决方案 > “没有名为 'django_heroku' 的模块”应用程序无法在 Heroku 上启动

问题描述

试图推送到heroku服务器,我得到了这个:

git push heroku master

remote: Building source:
remote:
remote: -----> Python app detected
remote:  !     Python has released a security update! Please consider upgrading to python-3.7.3
remote:        Learn More: https://devcenter.heroku.com/articles/python-runtimes
remote: -----> Installing requirements with pip
remote:
remote: -----> Downloading NLTK corpora…
remote:  !     'nltk.txt' not found, not downloading any corpora
remote:  !     Learn more: https://devcenter.heroku.com/articles/python-nltk
remote: -----> Discovering process types
remote:        Procfile declares types -> web
remote:
remote: -----> Compressing...
remote:        Done: 206.4M
remote: -----> Launching...
remote:        Released v10
remote:        https://versally.herokuapp.com/ deployed to Heroku

但是,当我转到我的应用程序时,它告诉我有一个错误。当我检查日志时,我看到:

2019-04-30T13:22:00.633794+00:00 app[web.1]: import django_heroku
2019-04-30T13:22:00.633801+00:00 app[web.1]: ModuleNotFoundError: No module named 'django_heroku'
2019-04-30T13:22:00.634020+00:00 app[web.1]: [2019-04-30 13:22:00 +0000] [11] [INFO] Worker exiting (pid: 11)
2019-04-30T13:22:00.789044+00:00 app[web.1]: [2019-04-30 13:22:00 +0000] [4] [INFO] Shutting down: Master

我还没有设置数据库,但我只是想从 django 代码中获取调试消息,这样我就可以开始配置数据库了。

标签: pythondjangoherokudeployment

解决方案


对于遇到此问题的任何人,我通过清空我的 requirements.txt、推送(这会迫使 Heroku 卸载所有需求)然后再次推送填充的需求来解决它。

我必须确保 gunicorn 包含在要求中 - 确实如此,但日志显示由于某种原因 heroku 卸载了我的“陈旧”版本。

Heroku + gunicorn 不工作(bash: gunicorn: command not found )


推荐阅读