I’m new developer from China.already being using django 1year.recently I create my first website with django,also websocket in it.
system centos7.6 nignx to proxy port.
and after I got the channels error
Traceback (most recent call last):
File “/data/env/pyweb/lib/python3.9/site-packages/uvicorn/protocols/websockets/websockets_impl.py”, line 244, in run_asgi
result = await self.app(self.scope, self.asgi_receive, self.asgi_send) # type: ignore[func-returns-value]
File “/data/env/pyweb/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py”, line 70, in call
return await self.app(scope, receive, send)
File “/data/env/pyweb/lib/python3.9/site-packages/channels/routing.py”, line 62, in call
return await application(scope, receive, send)
File “/data/env/pyweb/lib/python3.9/site-packages/channels/sessions.py”, line 47, in call
return await self.inner(dict(scope, cookies=cookies), receive, send)
File “/data/env/pyweb/lib/python3.9/site-packages/channels/sessions.py”, line 263, in call
return await self.inner(wrapper.scope, receive, wrapper.send)
File “/data/env/pyweb/lib/python3.9/site-packages/channels/auth.py”, line 185, in call
return await super().call(scope, receive, send)
File “/data/env/pyweb/lib/python3.9/site-packages/channels/middleware.py”, line 24, in call
return await self.inner(scope, receive, send)
File “/data/env/pyweb/lib/python3.9/site-packages/channels/routing.py”, line 132, in call
return await application(
File “/data/env/pyweb/lib/python3.9/site-packages/channels/consumer.py”, line 94, in app
return await consumer(scope, receive, send)
File “/data/env/pyweb/lib/python3.9/site-packages/channels/consumer.py”, line 58, in call
await await_many_dispatch(
File “/data/env/pyweb/lib/python3.9/site-packages/channels/utils.py”, line 57, in await_many_dispatch
await task
File “/data/env/pyweb/lib/python3.9/site-packages/channels/utils.py”, line 49, in await_many_dispatch
result = task.result()
File “/data/env/pyweb/lib/python3.9/site-packages/channels_redis/core.py”, line 353, in receive
message_channel, message = await self.receive_single(
File “/data/env/pyweb/lib/python3.9/site-packages/channels_redis/core.py”, line 408, in receive_single
content = await self._brpop_with_clean(
File “/data/env/pyweb/lib/python3.9/site-packages/channels_redis/core.py”, line 246, in _brpop_with_clean
result = await connection.bzpopmin(channel, timeout=timeout)
File “/data/env/pyweb/lib/python3.9/site-packages/redis/asyncio/client.py”, line 615, in execute_command
return await conn.retry.call_with_retry(
File “/data/env/pyweb/lib/python3.9/site-packages/redis/asyncio/retry.py”, line 59, in call_with_retry
return await do()
File “/data/env/pyweb/lib/python3.9/site-packages/redis/asyncio/client.py”, line 589, in _send_command_parse_response
return await self.parse_response(conn, command_name, **options)
File “/data/env/pyweb/lib/python3.9/site-packages/redis/asyncio/client.py”, line 636, in parse_response
response = await connection.read_response()
File “/data/env/pyweb/lib/python3.9/site-packages/redis/asyncio/connection.py”, line 570, in read_response
raise response from None
redis.exceptions.ResponseError: unknown command ‘BZPOPMIN’
I found a method to fix this problem, is to install channels-redis=2.4.2,but after I pip install it,django directly borken.with message!!
Traceback (most recent call last):
File “/data/env/pyweb/bin/uvicorn”, line 8, in
sys.exit(main())
File “/data/env/pyweb/lib/python3.9/site-packages/click/core.py”, line 1157, in call
return self.main(*args, **kwargs)
File “/data/env/pyweb/lib/python3.9/site-packages/click/core.py”, line 1078, in main
rv = self.invoke(ctx)
File “/data/env/pyweb/lib/python3.9/site-packages/click/core.py”, line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/data/env/pyweb/lib/python3.9/site-packages/click/core.py”, line 783, in invoke
return __callback(*args, **kwargs)
File “/data/env/pyweb/lib/python3.9/site-packages/uvicorn/main.py”, line 410, in main
run(
File “/data/env/pyweb/lib/python3.9/site-packages/uvicorn/main.py”, line 577, in run
server.run()
File “/data/env/pyweb/lib/python3.9/site-packages/uvicorn/server.py”, line 65, in run
return asyncio.run(self.serve(sockets=sockets))
File “/usr/local/lib/python3.9/asyncio/runners.py”, line 44, in run
return loop.run_until_complete(main)
File “uvloop/loop.pyx”, line 1517, in uvloop.loop.Loop.run_until_complete
File “/data/env/pyweb/lib/python3.9/site-packages/uvicorn/server.py”, line 69, in serve
await self._serve(sockets)
File “/data/env/pyweb/lib/python3.9/site-packages/uvicorn/server.py”, line 76, in _serve
config.load()
File “/data/env/pyweb/lib/python3.9/site-packages/uvicorn/config.py”, line 434, in load
self.loaded_app = import_from_string(self.app)
File “/data/env/pyweb/lib/python3.9/site-packages/uvicorn/importer.py”, line 19, in import_from_string
module = importlib.import_module(module_str)
File “/usr/local/lib/python3.9/importlib/init.py”, line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1030, in _gcd_import
File “”, line 1007, in _find_and_load
File “”, line 986, in _find_and_load_unlocked
File “”, line 680, in _load_unlocked
File “”, line 850, in exec_module File “”, line 228, in _call_with_frames_removed
File “/data/wwwroot/mysite1/mysite1/asgi.py”, line 21, in
from channels.auth import AuthMiddlewareStack
File “/data/env/pyweb/lib/python3.9/site-packages/channels/auth.py”, line 12, in
from django.contrib.auth.models import AnonymousUser
File “/data/env/pyweb/lib/python3.9/site-packages/django/contrib/auth/models.py”, line 3, in
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File “/data/env/pyweb/lib/python3.9/site-packages/django/contrib/auth/base_user.py”, line 57, in
class AbstractBaseUser(models.Model):
File “/data/env/pyweb/lib/python3.9/site-packages/django/db/models/base.py”, line 129, in new
app_config = apps.get_containing_app_config(module)
File “/data/env/pyweb/lib/python3.9/site-packages/django/apps/registry.py”, line 260, in get_containing_app_config
self.check_apps_ready()
File “/data/env/pyweb/lib/python3.9/site-packages/django/apps/registry.py”, line 137, in check_apps_ready
settings.INSTALLED_APPS
File “/data/env/pyweb/lib/python3.9/site-packages/django/conf/init.py”, line 102, in getattr
self._setup(name)
File “/data/env/pyweb/lib/python3.9/site-packages/django/conf/init.py”, line 82, in _setup
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
Wish anyone reply me the way to fix it, thanks, already spent me this whole weekend, 3 times same problem, almost have not courage to contine.waiting online…