You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

安装rediscluster时出现ModuleNotFoundError: No module named 'redis._compat'求助

解决ModuleNotFoundError: No module named 'redis._compat'问题

redis._compat是redis库内部的模块,无法通过单独pip安装获取,出现这个问题是因为redis和rediscluster版本不兼容导致的,按以下步骤解决:

  • 先卸载现有冲突的包:

    pip uninstall -y redis rediscluster
    
  • 方案一:安装兼容的旧版本组合
    rediscluster 2.x系列依赖redis 3.x/4.x版本(这些版本包含redis._compat模块),执行:

    pip install redis==3.5.3 rediscluster==2.1.3
    
  • 方案二:使用适配新版redis的包
    若想使用redis 5.x及以上版本,安装维护中的redis-py-cluster包(它已适配新版redis,不再依赖redis._compat):

    pip install redis-py-cluster
    
  • 验证安装
    打开Python交互终端,执行以下代码测试:

    from rediscluster import RedisCluster
    

    无报错则说明安装成功。

内容的提问来源于stack exchange,提问作者arexst

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.02 02:30:48