You need to enable JavaScript to run this app. 咨询Kaggle Notebook安装maraboupy时模块缺失与CMake报错的解决方法
优惠活动
大模型
产品
解决方案
定价
更多

咨询Kaggle Notebook安装maraboupy时模块缺失与CMake报错的解决方法

Kaggle Notebook 环境下 maraboupy 安装流程

核心报错根因

  • 仅克隆源码未编译生成C++扩展绑定时,会触发ModuleNotFoundError: No module named 'maraboupy.MarabouCore'错误
  • 直接执行原生cmake编译命令时,因Kaggle环境预装OpenBLAS的cmake识别逻辑冲突,会触发Cannot specify include directories for imported target "openblas"报错

分步安装操作

  • 第一步:拉取包含全部子模块的完整源码
    !git clone --recursive https://github.com/NeuralNetworkVerification/Marabou.git
    
  • 第二步:配置cmake编译参数,绕开OpenBLAS检测冲突
    显式指定当前Kaggle Python解释器路径、OpenBLAS实际安装路径,避免cmake触发导入目标属性错误:
    %cd /kaggle/working/Marabou
    !mkdir -p build && cd build
    !cmake .. \
      -DBUILD_PYTHON=ON \
      -DPYTHON_EXECUTABLE=/opt/conda/bin/python \
      -DOPENBLAS_INCLUDE_DIR=/usr/include/x86_64-linux-gnu \
      -DOPENBLAS_LIB=/usr/lib/x86_64-linux-gnu/libopenblas.so.0
    
  • 第三步:多线程执行编译,缩短等待时长
    利用Kaggle实例提供的多核资源并行编译,避免单线程编译耗时过长:
    !cmake --build . --parallel $(nproc)
    
  • 第四步:配置Python模块搜索路径,完成导入验证
    将Marabou源码根目录、编译输出目录加入Python搜索路径,即可正常导入模块:
    import sys
    sys.path.insert(0, '/kaggle/working/Marabou')
    sys.path.insert(0, '/kaggle/working/Marabou/build')
    # 验证导入
    from maraboupy import Marabou
    

兜底排查

若导入时仍提示maraboupy.MarabouCore缺失,可先定位编译生成的C++动态绑定文件路径,将对应目录手动加入sys.path即可:

!find /kaggle/working/Marabou -name "MarabouCore*.so"

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.31 01:45:10