{"id":"5067ab8df9750e27","repo":"redis/redis-py","slug":"hiredis-is-not-installed","errorCode":null,"errorMessage":"Hiredis is not installed","messagePattern":"Hiredis is not installed","errorType":"exception","errorClass":"RedisError","httpStatus":null,"severity":"error","filePath":"redis/_parsers/hiredis.py","lineNumber":112,"sourceCode":"        return bool(revents & closed_flags)\n    except OSError:\n        # The socket is errored (POLLERR/POLLNVAL); nothing left to read.\n        return True\n\n\nclass _HiredisReaderArgs(TypedDict, total=False):\n    protocolError: Callable[[str], Exception]\n    replyError: Callable[[str], Exception]\n    encoding: Optional[str]\n    errors: Optional[str]\n\n\nclass _HiredisParser(BaseParser, PushNotificationsParser):\n    \"Parser class for connections using Hiredis\"\n\n    def __init__(self, socket_read_size):\n        if not HIREDIS_AVAILABLE:\n            raise RedisError(\"Hiredis is not installed\")\n        self.socket_read_size = socket_read_size\n        self._buffer = bytearray(socket_read_size)\n        self.pubsub_push_handler_func = self.handle_pubsub_push_response\n        self.node_moving_push_handler_func = None\n        self.maintenance_push_handler_func = None\n        self.oss_cluster_maint_push_handler_func = None\n        self.invalidation_push_handler_func = None\n        self._hiredis_PushNotificationType = None\n\n    def __del__(self):\n        try:\n            self.on_disconnect()\n        except Exception:\n            pass\n\n    def handle_pubsub_push_response(self, response):\n        logger = getLogger(\"push_response\")\n        logger.debug(\"Push response: %s\", response)","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/redis/redis-py/blob/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/_parsers/hiredis.py#L94-L130","documentation":"Raised by _HiredisParser.__init__() when redis.utils.HIREDIS_AVAILABLE is False - i.e. the optional hiredis-py package is not importable. The parser is only constructed when the connection is configured to use the hiredis parser; without the C extension the parser cannot be created. Plain RedisError, error_type=SERVER.","triggerScenarios":"Setting parser_class=_HiredisParser (or via a client config that selects it) in an environment where hiredis is not installed; the installed hiredis is older than 3.2.0 (HIREDIS_AVAILABLE checks importability/version); broken hiredis build that fails to import.","commonSituations":"Deploying without the 'hiredis' extra (pip install redis[hiredis]); using a slim Docker image lacking build tools; mixed Python versions in a venv where hiredis was compiled for a different ABI; pinning redis-py but forgetting the optional C extension.","solutions":["Install hiredis: pip install hiredis (or pip install redis[hiredis]).","Verify the install imports: python -c 'import hiredis; print(hiredis.__version__)'.","If you cannot install hiredis, drop the parser_class override so the pure-Python parser is used.","Rebuild hiredis against the running Python ABI after a Python version bump."],"exampleFix":"// before\nr = redis.Redis(..., parser_class=redis.parsers.HiredisParser)\n# RedisError: Hiredis is not installed\n\n// after\n# option A: install it\n#   pip install hiredis\n# option B: fall back to the pure-Python parser\nr = redis.Redis(...)  # do not set parser_class","handlingStrategy":"validation","validationCode":"# Verify hiredis is importable before constructing a client that needs it\nimport importlib.util, redis.utils\nif not importlib.util.find_spec(\"hiredis\"):\n    raise RuntimeError(\"install 'hiredis' or drop the parser_class override\")\nassert redis.utils.HIREDIS_AVAILABLE","typeGuard":null,"tryCatchPattern":"try:\n    r = redis.Redis(..., parser_class=redis.parsers.HiredisParser)\nexcept redis.exceptions.RedisError as e:\n    if \"Hiredis is not installed\" in str(e):\n        # fall back to the pure-Python parser\n        r = redis.Redis(...)","preventionTips":["Install via the extra: pip install redis[hiredis].","Verify in CI: python -c 'import hiredis'.","Do not hard-code parser_class unless hiredis is a declared dependency.","Rebuild hiredis after any Python ABI change."],"tags":["hiredis","dependency","config","sync"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}