Resolving ImportError: Module "redis.connection" does not define a "HiredisParser" attribute/class

290 views Asked by At

My django project has this issue after I updated my redis to version 5.4.0. It seems that the HiredisParser that I was using in my PARSER_CLASS in the redis configuration could not be found in this update. After taking a look at the change log, it seems the issue is a rename of the HiredisParser class from HiredisParser to _HiredisParser.

So a simple change from this:

"PARSER_CLASS": "redis.connection.HiredisParser"

to this:

"PARSER_CLASS": "redis.connection._HiredisParser"

should fix the issue.

Note that if hiredis package is already installed you can remove the whole line completely in your django cache configuration as it will by default select _HiredisParser if hiredis is installed.

Relevant source: https://github.com/jazzband/django-redis/issues/676

0

There are 0 answers