ModuleNotFoundError: No module named 'channels.http'

I found a couple of similar questions, but nothing really helped. I tried updating asgiref version and also updated channels and django-eventstream. I mainly followed the instruction from the django-eventstream-setup page.

relevant packages from my setup:

Package            Version
------------------ ---------
asgiref            3.6.0
channels           4.0.0
Django             4.1.2
django-eventstream 4.5.1
django-grip        3.2.0
django-htmx        1.12.2
gripcontrol        4.1.0
huey               2.4.3
MarkupSafe         2.1.2
requests           2.28.1
Werkzeug           2.2.2

The error I get upon executing python runserver:

File "...\venv\lib\site-packages\django_eventstream\", line 2, in <module>
    from . import consumers
File "...\venv\lib\site-packages\django_eventstream\", line 7, in <module>
    from channels.http import AsgiRequest
ModuleNotFoundError: No module named 'channels.http'

I created an file next to

import os
from django.core.asgi import get_asgi_application
from django.urls import path, re_path
from channels.routing import ProtocolTypeRouter, URLRouter
from channels.auth import AuthMiddlewareStack
import django_eventstream

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'channels_test.settings')

application = ProtocolTypeRouter({
    'http': URLRouter([
        path("events/", AuthMiddlewareStack(URLRouter(django_eventstream.routing.urlpatterns)), { 'channels': ['test'] }),
        re_path(r"", get_asgi_application()),

In I updated for using asgi:

WSGI_APPLICATION = "channels_test.wsgi.application"
ASGI_APPLICATION = "channels_test.asgi.application"

This is the folder structure:

enter image description here

Use channels version 3.0.5! Authors django-eventstream didn't update own docs)

you should change your channels version to 3.0.5, this version is compatible with django-eventstream==4.5.1.

Back to Top