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

Chaquopy安装numba时提示找不到numpy问题求助

解决Chaquopy中安装numba时提示找不到numpy的问题

原因分析

numba安装过程中会编译依赖numpy的扩展代码,但Chaquopy默认的包安装逻辑可能导致numba启动安装时,numpy还未完成安装或未被环境正确识别。而单独安装numpy时环境已就绪,因此能正常运行。

解决方案

1. 调整pip包安装顺序

在build.gradle的Chaquopy配置中,将numpy放在numba之前,确保numpy先完成安装:

chaquopy {
    defaultConfig {
        pythonVersion "3.8"
        pip {
            install "cython"
            install "numpy==1.24.4"
            install "numba==0.60.0"  // 注:你配置的numba==0.6.0版本过旧,与numpy 1.24.4兼容性极差,建议改用0.60.0
            install "galois"
        }
    }
}

2. 合并为单个pip安装指令

把所有依赖写在同一个install指令中,让pip自动按依赖优先级处理安装顺序:

chaquopy {
    defaultConfig {
        pythonVersion "3.8"
        pip {
            install "cython numpy==1.24.4 numba==0.60.0 galois"
        }
    }
}

3. 关闭numba的构建隔离(极端情况)

如果前两种方法无效,可关闭numba的构建隔离,强制它在已安装numpy的环境中编译:

chaquopy {
    defaultConfig {
        pythonVersion "3.8"
        pip {
            install "numpy==1.24.4"
            install "numba==0.60.0" --install-option="--no-build-isolation"
            install "cython"
            install "galois"
        }
    }
}

验证步骤

  1. 清理项目缓存:执行./gradlew clean
  2. 重新构建项目:执行./gradlew assembleDebug
  3. 运行项目,检查galois与numba是否能正常导入使用

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.06 11:09:55