need help!!!after pip install channels-redis==2.4.2,Project broken directly,cant fixed.!!

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…

Welcome @weekman123 !

That version of channels-redis is probably way too old.

Please show what versions of Python, Django, channels, daphne, and redis (not channels-redis, you’ve already shown that) you have installed.

Also show what version of redis you have installed in your os.

python 3.9.19
channels 2.4.0
channels-redis 4.2.0 this one is now using ,directly install without version fixed.
daphne 2.5.0
Django 4.2.15
django-redis 5.4.0
pip 24.1
redis 5.0.8
uvicorn 0.30.5

but about the redis version ,here is using the order can get different one.
[root@HK02-5038ML-003-04 mysite1]# redis-server --version
Redis server v=3.2.12 sha=00000000:0 malloc=jemalloc-3.6.0 bits=64 build=7897e7d0e13773f

now I dont know if I can contine to fix the channels-redis ,before my 2 broken project repiared, I’m fearing to contine.:),thanks for replys

thanks for your reply, even i dont know how to repair the project back to be working.

You’ve got a couple of mixed version issues. I’d be tempted to delete this entire virtual environment and create a new one.

Current version is 4.1.0

Current version is 4.1.2

And this is only what you’ve shown here. There may be other packages involved that are seriously out-of-date.

Perhaps most significantly:

You should bring that up to at least redis 5.0, and probably something more current than that.

So because I’m using centos.7.6, after fixed version install it’s will be better?Django version on my local cumputer its.5.0.6 ,but the centos server only supply the newest is 4.2.15,and redis from pip list we can see its 5.06,why it’s showing 3.2.12

It’s got nothing (directly) to do with you using CentOS 7.6.

Quoting directly from the docs for the redis package on pypi.org

The most recent version of this library supports redis version 5.0, 6.0, 6.2, 7.0 and 7.2.

Note that the redis package is different software from the Python redis library. They are two separate packages. (The Python redis library is what provides access to the redis package from other Python code.)

Thanks for your suggestions , I will try to download new one ,because just find it’s worse now… ,even only website working,disable the websocket functions. the project can be running.

Come back agian, just want to say!

Thanks, all fixed, the broken reason maybe when I pip old version channels-redis,the channels auto degrade to older version ,then ,my django cant using it…