I installed Redis version 4.0.9 in a Ubuntu Linux Subsystem on Windows 10 by following these instructions (i.e. sudo apt-get install redis-server
).
I am following this tutorial on Django channels, and I ran the following code:
>>> import channels.layers
>>> channel_layer = channels.layers.get_channel_layer()
>>> from asgiref.sync import async_to_sync
>>> async_to_sync(channel_layer.send)('test_channel', {'type': 'hello'})
>>> async_to_sync(channel_layer.receive)('test_channel')
When the last line above is executed, I get this error:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:UsersxyzAnaconda3envsdjangolibsite-packagesasgirefsync.py", line 120, in __call__
return call_result.result()
File "C:UsersxyzAnaconda3envsdjangolibconcurrentfutures_base.py", line 425, in result
return self.__get_result()
File "C:UsersxyzAnaconda3envsdjangolibconcurrentfutures_base.py", line 384, in __get_result
raise self._exception
File "C:UsersxyzAnaconda3envsdjangolibsite-packagesasgirefsync.py", line 180, in main_wrap
result = await self.awaitable(*args, **kwargs)
File "C:UsersxyzAnaconda3envsdjangolibsite-packageschannels_rediscore.py", line 485, in receive
return (await self.receive_single(channel))[1]
File "C:UsersxyzAnaconda3envsdjangolibsite-packageschannels_rediscore.py", line 508, in receive_single
index, channel_key, timeout=self.brpop_timeout
File "C:UsersxyzAnaconda3envsdjangolibsite-packageschannels_rediscore.py", line 345, in _brpop_with_clean
result = await connection.bzpopmin(channel, timeout=timeout)
aioredis.errors.ReplyError: ERR unknown command 'BZPOPMIN'
On this page, someone suggested using Redis version 5. How do I install Redis version 5 on Windows 10? Any other ideas on how to solve this issue?
11
Answers
There is no official support for Redis in Windows OS.
However, Microsoft develops and maintains microsoftarchive/redis. Also it is no longer supported (older versions are availble). I had long search on this about installing version 5 in windows 10. But no luck.
Better you can go for Memurai. Memurai is 100% compatible with the Redis protocol (also supported version 5 too). It is free for development and testing.
EDIT : From Itamar comment, u can also use this as alternative for Memurai
This is how i resolve this issue.
Ubuntu 18 installs redis 4 but ubuntu 20 installs redis 5. You can find your redis version by typing
redis-cli -v
. So i uninstall ubuntu 18 from my windows subsystem for linux (WSL) and reinstall ubuntu 20. It worked just fine.Use redis 5.0.9. It worked for for the same error.
Get it from github.com/tporadowski/redis/releases
I think the problem is in the compatibility with version of the channels-redis package! I had already tested channels some time ago and it worked beautifully with channels-redis version 2.4.2, recently they are in version 3.0.1 and this version doesn’t work properly yet I don’t know why.
Try install the version 2.4.2 with pip:
Problem is with the version.
Try older one
I found "2,3,4" any version with it stable and properly working.
https://github.com/tporadowski/redis/releases
Just download the latest version of Redis for Windows https://github.com/tporadowski/redis/releases from here it will work.
you don’t need to downgrade the version of your channels-redis etc. This problem with Redis not with any python packages at all.
To add to @Marvin answer, for me it was similar (some versioning problem probably), I reinstalled django_channels and django to the exact version as specified in the tutorial (3.0, 2.2) and it worked. Not sure what exactly worked but recommend checking it:)
You need to install the latest version(6+) of
redis
:then restart the
redis-server
.Same problem on Ubuntu 16.04
Similarly, I was following the chat application tutorial on Django Channels website and had the same error:
The problem occurred when I used these versions:
Thanks to @marvin-correia for his answer I figured out the problem’s reason is the version of the
channels-redis
package! So as he suggested, I installed channel-redis version 2.4.2 and the error has gone.Also, I’ve to note that channels package downgraded to
channels==2.4.0
automatically.I will also confirm Marvins answer. Hopefully this will help someone out but also leaving this here for notes.
Development:
(this setup works) considering data is sent to and form http://localhost:8000
Setup
Windows 10 Running WSL with Ubuntu 20.04
Production
setup
When I downgraded, channels-redis, it automcatically downgraded channels as well. Then you can force the upgrade to channels==3.0.3, but it will raise an incompatibility error. Also, if 2 files will most likely to be updated to run Django 4.0
1 being here
https://github.com/django/channels/issues/1609
I was getting this error on a Windows machine, I would suggest you to use Redis on a docker image instead of using Redis server on a windows machine.
One of the way to run a redis server via a docker image and map the port 6379 is to:
start docker desktop
In your terminal type the below command.
docker run -p 6379:6379 -d redis:5