I’m trying the connect to a redis cluster with the below code.
import redis
ssl_ca_certs='<path_to_ca_certfile>'
r = redis.RedisCluster(
host='<RedisHOST>',
port=6379,
ssl=True,
password='<password>',
ssl_ca_certs=ssl_ca_certs
)
The code was working fine for some time. but recently I’m getting error
Traceback (most recent call last):
File "/home/rnatarajan/network-signals/py-demo/get-redis-cli.py", line 7, inr = redis.RedisCluster(
AttributeError: module ‘redis’ has no attribute ‘RedisCluster’
I tried uninstalling and reinstalling the redis package.
I uninstalled redis-py-cluster
package.
Note: I’m using ubuntu 22.04
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.2 LTS
Release: 22.04
Codename: jammy
I’m using python 3.10
$ python3 --version
Python 3.10.12
Any idea how to fix this error?
2
Answers
I think it should be used like this:
redis-py (
pip install redis
) now supports clustering so you shouldn’t need an additional package. Try something like this:Reference: https://redis.readthedocs.io/en/stable/clustering.html#