推送到heroku:没有名为'channels'的模块

时间:2017-10-12 08:03:40

标签: django heroku django-channels

当我将'channels'添加到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但是服务器崩溃了

卸载频道并重新安装

任何人都可以给我一些提示,谢谢。

1 个答案:

答案 0 :(得分:1)

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

django频道的正确套餐实际上是频道

所以就这样做:

  1. 列出名称
  2. 中包含频道的所有已安装软件包
      

    点子列表| grep频道

    输出:

      

    频道(1.1.6)

         

    channels-api(0.4.0)

         

    django-channels(0.7.0)

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

      pip install channels

      1. 使用以下方式创建 requirements.txt
      2.   

        pip freeze&gt; requirements.txt