繁体   English   中英

“没有名为‘django_heroku’的模块”应用程序无法在 Heroku 上启动

[英]"No module named 'django_heroku' " app won't start on 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 代码中获取调试消息,这样我就可以开始配置数据库了。

我自己遇到了这个问题并发现了这个问题。 如果找不到模块,就会发生此错误,正如错误名称所解释的那样。 如果推送到 heroku 的代码中不包含包含该模块的虚拟环境,则无法找到该模块。

如果你使用 pipenv 作为你的虚拟环境,你会得到这个错误。 要解决此问题,您需要执行以下操作:

  1. 删除 Pipfile 和 Pipfile.lock 文件。

  2. 在 pipenv 之外,发出以下命令:

python -m venv virtual_environment_name

virtual_environment_name/Scripts/Activate (Windows)

source virtual_environment_name/bin/activate (Mac)

  1. 再次安装之前安装的软件包。

  2. 运行git add . git commit -am "Some text here"命令。

你应该很高兴去!

对于存在此问题的任何人,我都可以通过清空我的requirements.txt,推送(这将迫使Heroku卸载所有需求)然后通过重新推送填充的需求来解决。

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

Heroku + Gunicorn不起作用(bash:gunicorn:找不到命令)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM