【问题标题】:Push to heroku: no module named 'channels'推送到heroku:没有名为“频道”的模块
【发布时间】:2017-10-12 08:03:40
【问题描述】:

当我将“频道”添加到 INSTALLED_APPS 时遇到此错误

Writing objects: 100% (4/4), 351 bytes | 0 bytes/s, done.
Total 4 (delta 3), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: -----> Installing requirements with latest Pipenv…
remote:        Installing dependencies from Pipfile.lock (36121f)…
remote: -----> $ python manage.py collectstatic --noinput
remote:        Traceback (most recent call last):
remote:          File "manage.py", line 10, in <module>
remote:            execute_from_command_line(sys.argv)
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
remote:            utility.execute()
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 337, in execute
remote:            django.setup()
remote:          File "/app/.heroku/python/lib/python3.6/site-    packages/django/__init__.py", line 27, in setup
remote:            apps.populate(settings.INSTALLED_APPS)
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/registry.py", line 85, in populate
remote:            app_config = AppConfig.create(entry)
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/config.py", line 94, in create
remote:            module = import_module(entry)
remote:          File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
remote:            return _bootstrap._gcd_import(name[level:], package, level)
remote:          File "<frozen importlib._bootstrap>", line 978, in _gcd_import
remote:          File "<frozen importlib._bootstrap>", line 961, in _find_and_load
remote:          File "<frozen importlib._bootstrap>", line 948, in _find_and_load_unlocked
remote:        ModuleNotFoundError: No module named 'channels'
remote:
remote:  !     Error while running '$ python manage.py collectstatic --noinput'.
remote:        See traceback above for details.
remote:
remote:        You may need to update application code to resolve this error.
remote:        Or, you can disable collectstatic for this application:
remote:
remote:           $ heroku config:set DISABLE_COLLECTSTATIC=1
remote:
remote:        https://devcenter.heroku.com/articles/django-assets
remote:  !     Push rejected, failed to compile Python app.
remote:
remote:  !     Push failed    

到目前为止我尝试了什么:

我禁用了 collectstatic,它能够将代码推送到 heroku 但服务器崩溃了

卸载频道并重新安装

谁能给我一些建议,谢谢。

【问题讨论】:

  • 在你的 requirements.txt 中吗?显示该文件。
  • 我在requirements.txt中找到了,如下列表 asgi-redis==1.4.3 asgiref==1.1.2 astroid==1.5.3 attrs==17.2.0 autobahn==17.9 .3 Automat==0.6.0 certifi==2017.7.27.1 channels==1.1.8 chardet==3.0.4 colorama==0.3.9 不断==15.1.0 daphne==1.3.0 decorator==4.1.2 dj-database-url==0.4.2 Django==1.11.6 flake8==3.4.1 超链接==17.3.1 idna==2.6 增量==17.5.0 ipython==6.2.1 ipython-genutils==0.2 .0 isort==4.2.15 jedi==0.11.0 lazy-object-proxy==1.3.1
  • 抱歉格式不明确....请看下面!Valid XHTML
  • @Kaspar 你把channels 添加到INSTALLED_APPS 了吗?请出示您的settings.py

标签: django heroku django-channels


【解决方案1】:

我有同样的问题。问题是由于我使用 django-channels(还有 django_channels)而不是 channels

django 频道的正确包实际上是 channels

那么就这样做吧:

  1. 列出所有已安装的软件包,名称中包含 channels

点列表 | grep 频道

输出:

频道 (1.1.6)

channels-api (0.4.0)

django 频道 (0.7.0)

  1. 使用 pip uninstall package-name 卸载每个(甚至频道): 例如:pip 卸载 django-channels
  2. 仅使用以下方式重新安装频道(witch 称为 channels 而不是 'django-channels' 或 'django_channels')包:

pip 安装渠道

  1. 使用以下命令创建 requirements.txt

pip freeze > requirements.txt

【讨论】:

  • 感谢您的回复,没有其他与软件包相关的渠道.. 我遵循了 heroku 的入门公会,尚未安装其他软件包。所以我真的很困惑发生了什么......
猜你喜欢
  • 2019-07-30
  • 2012-11-17
  • 2018-08-21
  • 2012-07-16
  • 2012-07-20
  • 2018-04-11
  • 2012-09-22
  • 2015-03-18
  • 2021-01-13
相关资源
最近更新 更多