{"id":"73ffdb183de73c6c","repo":"redis/redis-py","slug":"hiredis-package-should-be-3-2-0","errorCode":null,"errorMessage":"hiredis package should be >= 3.2.0","messagePattern":"hiredis package should be >= 3\\.2\\.0","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"info","filePath":"redis/utils.py","lineNumber":26,"sourceCode":"from functools import wraps\nfrom typing import TYPE_CHECKING, Any, Dict, List, Mapping, Optional, TypeVar, Union\n\nfrom redis.exceptions import DataError\nfrom redis.typing import AbsExpiryT, EncodableT, ExpiryT\n\nif TYPE_CHECKING:\n    from redis.client import Redis\n\ntry:\n    import hiredis  # noqa\n\n    # Only support Hiredis >= 3.0:\n    hiredis_version = hiredis.__version__.split(\".\")\n    HIREDIS_AVAILABLE = int(hiredis_version[0]) > 3 or (\n        int(hiredis_version[0]) == 3 and int(hiredis_version[1]) >= 2\n    )\n    if not HIREDIS_AVAILABLE:\n        raise ImportError(\"hiredis package should be >= 3.2.0\")\nexcept ImportError:\n    HIREDIS_AVAILABLE = False\n\ntry:\n    import ssl  # noqa\n\n    SSL_AVAILABLE = True\nexcept ImportError:\n    SSL_AVAILABLE = False\n\ntry:\n    import cryptography  # noqa\n\n    CRYPTOGRAPHY_AVAILABLE = True\nexcept ImportError:\n    CRYPTOGRAPHY_AVAILABLE = False\n\nfrom importlib import metadata","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/redis/redis-py/blob/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/utils.py#L8-L44","documentation":"Raised at redis/utils.py:26 inside the optional-hiredis import block. The library parses hiredis.__version__ and requires >= 3.2.0; if an older hiredis is installed it does `raise ImportError('hiredis package should be >= 3.2.0')`. This ImportError is caught by the immediately-enclosing `except ImportError` (line 27), which sets HIREDIS_AVAILABLE=False and falls back to the pure-Python RESP parser. Users normally never observe the exception directly; the only observable effect is that the C-accelerated hiredis parser is silently disabled.","triggerScenarios":"Importing redis (or any module that imports redis.utils) in an environment where an older hiredis (< 3.2.0, e.g. 2.x, 3.0.x, 3.1.x) is installed. The version check at lines 22-24 evaluates HIREDIS_AVAILABLE=False and the inner raise triggers the except branch.","commonSituations":"Stale virtualenv pinning hiredis<3.2; OS distribution packages shipping older hiredis; transitive dependency caps from another library; CI image with an old hiredis wheel; recent redis-py upgrade without upgrading hiredis.","solutions":["Upgrade hiredis: pip install -U 'hiredis>=3.2.0'.","If you cannot upgrade, uninstall hiredis (pip uninstall hiredis) so the import simply fails into HIREDIS_AVAILABLE=False without the version warning.","Run pip check to detect dependency conflicts capping hiredis.","Pin hiredis>=3.2.0 in requirements.txt / pyproject.toml."],"exampleFix":"# before (requirements.txt)\nhiredis==2.3.0\n# after\nhiredis>=3.2.0","handlingStrategy":"validation","validationCode":"import hiredis\n\ndef hiredis_version_ok() -> bool:\n    parts = hiredis.__version__.split('.')\n    return int(parts[0]) > 3 or (int(parts[0]) == 3 and int(parts[1]) >= 2)\n\n# At app startup\ntry:\n    import hiredis\n    if not hiredis_version_ok():\n        raise RuntimeError(f'hiredis {hiredis.__version__} is too old; upgrade to >=3.2.0')\nexcept ImportError:\n    pass  # pure-Python parser will be used","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin hiredis>=3.2.0 alongside redis in requirements.txt / pyproject.toml.","Run `pip check` in CI to catch version conflicts.","Recreate virtualenvs after upgrading redis-py to avoid stale hiredis wheels.","Monitor logs/telemetry for the hiredis-disabled state if parser throughput matters."],"tags":["hiredis","dependencies","versioning","performance","parser"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}