question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[3.x] aiogram is looking for redis when aioredis is installed (fix imports)

See original GitHub issue

Checklist

  • I am sure the error is coming from aiogram code
  • I have searched in the issue tracker for similar bug reports, including closed ones

Operating system

macos 12.2.1 (21D62)

Python version

3.9

aiogram version

3.0.0b5

Expected behavior

redis fsm storage works with aioredis

Current behavior

redis fsm storage does not work with aioredis

Steps to reproduce

install aiogram 3.0.0.b5 install aioredis pip install aioredis. Currently 2.0.1 create redis client redis_client = Redis.from_url("redis://localhost:6379/3") create dispatcher dp = Dispatcher(storage=RedisStorage(redis=redis_client))

Code example

from aiogram.fsm.storage.redis import RedisStorage
from aioredis.client import Redis

redis_client = Redis.from_url("redis://localhost:6379/3")
dp = Dispatcher(storage=RedisStorage(redis=redis_client))

Logs

Traceback (most recent call last):
  File "/Users/dev/projects/OWN/shopping_bot/src/bot/bot.py", line 6, in <module>
    from aiogram.fsm.storage.redis import RedisStorage
  File "/Users/dev/projects/OWN/shopping_bot/venv/lib/python3.9/site-packages/aiogram/fsm/storage/redis.py", line 5, in <module>
    from redis.asyncio.client import Redis
ModuleNotFoundError: No module named 'redis'

Additional information

imports failing in …/env/lib/python3.9/site-packages/aiogram/fsm/storage/redis.py

from redis.asyncio.client import Redis from redis.asyncio.connection import ConnectionPool from redis.asyncio.lock import Lock from redis.typing import ExpiryT

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
evgfilim1commented, Oct 19, 2022

there’s no asyncio in redis

There is. Maybe you’re encountering a bug in PyCharm typeshed stubs, which don’t know about redis.asyncio. See https://youtrack.jetbrains.com/issue/PY-53965/.

1reaction
andrew000commented, Oct 18, 2022

fixing:

  1. go to file aiogram/fsm/storage/redis.py
  2. replace imports
from redis.asyncio.client import Redis
from redis.asyncio.connection import ConnectionPool 
from redis.asyncio.lock import Lock
from redis.typing import ExpiryT

with

from aioredis.client import Redis, ExpiryT
from aioredis.connection import ConnectionPool 
from aioredis.lock import Lock

Check this link https://github.com/aio-libs/aioredis-py#-aioredis-is-now-in-redis-py-420rc1-


image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Aioredis is now in redis-py 4.2.0rc1! · Issue #1301 - GitHub
Aioredis is now in redis-py 4.2.0rc1+ To install, just do pip install redis>=4.2.0rc1. The code is almost the exact same.
Read more >
Getting Started - aioredis
aioredis.from_url creates a Redis client backed by a pool of connections. The only required argument is the URL, which should be string representing...
Read more >
aioredis 1.3.0 documentation - Read the Docs
The library is intended to provide simple and clear interface to Redis based on ... The easiest way to install aioredis is by...
Read more >
API Reference — aioredis 1.3.0 documentation - Read the Docs
Redis Connection is the core function of the library. Connection instances can be used as is or through pool or high-level API. Connection...
Read more >
aioredis 0.3.0 documentation - Read the Docs
hiredis parser, Yes. Pure-python parser, TBD. Low-level & High-level APIs, Yes. Connections Pool, Yes. Pipelining support, Yes. Pub/Sub support, Yes. Redis ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found