{"record":{"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/6a6b581b48225afa0b76912d1028c6035baee932/redis/_parsers/hiredis.py#L94-L130","documentation":"Raised in _HiredisParser.__init__() (redis/_parsers/hiredis.py:112) when the sync hiredis parser is constructed but hiredis-py is not importable (HIREDIS_AVAILABLE is False). The hiredis parser is the C-accelerated RESP parser used when the 'hiredis' extra is installed; without the package it cannot be created.","triggerScenarios":"A connection is explicitly configured to use the hiredis parser (or code constructs _HiredisParser directly) while hiredis-py is not installed in the environment.","commonSituations":"Deploying without 'pip install redis[hiredis]' (or 'pip install hiredis'); CI/container image missing the extra; a platform where the hiredis wheel isn't available; importing the parser unconditionally in custom code.","solutions":["Install hiredis: 'pip install hiredis' or 'pip install redis[hiredis]' (pin hiredis>=3.2.0 for full feature support).","If you don't need hiredis, don't request it — let the client use the pure-Python parser (the default).","Verify the install with: python -c 'import hiredis; print(hiredis.__version__)'.","For custom code, gate the parser selection on redis.utils.HIREDIS_AVAILABLE."],"exampleFix":"# before\n# parser selected as hiredis but package missing -> RedisError('Hiredis is not installed')\n\n# after\n# pip install hiredis\nr = redis.Redis(...)  # hiredis auto-used when present, no explicit parser needed","handlingStrategy":"validation","validationCode":"from redis.utils import HIREDIS_AVAILABLE\nif not HIREDIS_AVAILABLE:\n    raise RuntimeError(\"install hiredis: pip install redis[hiredis]\")\n# now safe to use the hiredis parser","typeGuard":null,"tryCatchPattern":"try:\n    from redis._parsers.hiredis import _HiredisParser\n    parser = _HiredisParser(socket_read_size=65536)\nexcept redis.RedisError as e:\n    if \"Hiredis is not installed\" in str(e):\n        # fall back to the pure-Python parser instead of failing\n        ...","preventionTips":["Install 'pip install redis[hiredis]' (pin hiredis>=3.2.0) when you want the C parser.","Don't explicitly request the hiredis parser unless the extra is installed — the client auto-selects it when present.","Verify with python -c 'import hiredis' in your deploy/CI image."],"tags":["dependency","hiredis","config","environment"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}