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

使用umap-learn遇“Numba需NumPy 1.24或更低”错误求助

解决umap-learn导入时"Numba needs NumPy 1.24 or less"错误的进阶方案

问题根源分析

当前环境显示numpy为1.23.5、numba为0.57.1但错误依旧,大概率是多版本numpy共存、numba未正确关联降级后的numpy,或是conda依赖缓存未更新导致实际调用的仍是不兼容版本。

具体解决步骤

  • 创建全新隔离conda环境
    彻底规避旧环境的依赖混乱:

    conda create -n umap_env python=3.9
    conda activate umap_env
    

    选择Python 3.9是因为它对numba 0.57.1和numpy 1.23.5的兼容性更稳定。

  • 指定兼容版本组合安装
    直接用conda安装经过验证的版本组合,让包管理器自动处理依赖:

    conda install -c conda-forge numpy=1.23.5 numba=0.57.1 scipy=1.10.1 scikit-learn=1.2.2 umap-learn=0.5.3
    
  • 验证依赖绑定一致性
    安装完成后在Python环境中执行以下命令,确认numba识别的numpy版本:

    import numpy
    import numba
    print(numpy.__version__)  # 需输出1.23.5
    print(numba.__version__)  # 需输出0.57.1
    print(numba.numpy_support.NUMPY_VERSION)  # 确认numba关联的numpy版本
    

    如果最后一行输出不是1.23.5,重新安装numba:

    pip uninstall numba -y
    pip install numba==0.57.1 --no-cache-dir
    
  • 清理pip/conda混合安装残留
    若之前混合使用过两种包管理器,先清理冲突包:

    pip freeze | grep -E "numpy|numba|umap-learn" | xargs pip uninstall -y
    

    之后完全用conda重新安装所有依赖。

额外注意事项

  • 不要单独手动降级numpy,umap-learn的依赖链中numba与numpy版本绑定严格,单独操作会破坏依赖关联。
  • 确保conda-forge为最高优先级channel,避免拉取不兼容版本:
    conda config --add channels conda-forge
    conda config --set channel_priority strict
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.10 21:53:14