Search code examples
pythonredisaioredis

AttributeError: 'Redis' object has no attribute 'pubsub'


I am starting to use aioredis and I can't manage to create a Redis pubsub object with aioredis, despite following the recipe from the documentation.

Here's my code:

redis = await aioredis.create_redis(url, encoding="utf-8")
sub = redis.pubsub()
await sub.subscribe(channel)

I am getting the error: AttributeError: 'Redis' object has no attribute 'pubsub'

Output of python3 -m pip show aioredis:

Name: aioredis
Version: 1.3.1
Summary: asyncio (PEP 3156) Redis support
Home-page: https://github.com/aio-libs/aioredis
Author: Alexey Popravka
Author-email: [email protected]
License: MIT

Solution

  • I think you are failed to init redis variable