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

安装Scipy时Ninja编译失败:numpy无get_include属性错误

解决安装Ninja时的AttributeError: module 'numpy' has no attribute 'get_include'错误

这个报错的核心原因是numpy 2.x及以上版本移除了get_include()函数,而当前Ninja的源码构建逻辑还依赖这个旧API,导致wheel编译失败。以下是可行的解决方法:

方法1:降级numpy到兼容版本

安装一个稳定的旧版numpy(比如1.26.x系列,完全兼容Ninja的构建需求):

pip install numpy==1.26.4 --force-reinstall

完成后重新执行Ninja安装:

pip install ninja

方法2:跳过源码构建,直接安装预编译wheel

如果不想降级numpy,可以直接下载对应系统的预编译Ninja wheel包,避免源码编译步骤:

  1. 找到匹配你Python版本、系统架构的Ninja wheel文件(比如ninja-1.11.1.1-py2.py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl)
  2. 用pip安装本地wheel文件:
pip install /path/to/downloaded/ninja-wheel.whl

方法3:用conda安装(适用于conda环境)

如果你的环境由conda管理,直接通过conda-forge安装Ninja,无需处理依赖冲突:

conda install -c conda-forge ninja

验证安装成功

执行以下命令确认Ninja已正确安装:

ninja --version

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.18 18:51:01