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

运行Bazel Build构建MediaPipe姿态检测生成AAR文件时出错

解决MediaPipe编译Android AAR时的Python工具链DeclaredToolchainInfo错误

问题场景

在尝试为Android Studio生成MediaPipe姿态检测的AAR文件时,执行编译命令:

build -c opt --config=android_arm64 mediapipe/modules/pose_detection:*

出现如下错误:

ERROR: C:/users/asrock/downloads/mediapipe-master/mediapipe/framework/tool/BUILD:109:10: While resolving toolchains for target //mediapipe/framework/tool:encode_as_c_string: invalid registered toolchain '@local_execution_config_python//:py_toolchain': target does not provide the DeclaredToolchainInfo provider
ERROR: Analysis of target '//mediapipe/modules/pose_detection:pose_detection_cpu.inc' failed; build aborted:
INFO: Elapsed time: 0.441s
INFO: 0 processes.
FAILED: Build did NOT complete

解决方法

  • 验证Python环境合规性
    MediaPipe master分支对Python版本有明确要求,需使用Python 3.8~3.10。执行python --version或python3 --version确认当前版本符合范围,同时确保Python已添加到系统环境变量,能在任意目录正常调用。

  • 指定Bazel使用的Python路径
    在MediaPipe根目录下创建或编辑.bazelrc.local文件,添加以下配置(替换为你的实际Python路径):

    build --python_path=C:/Python39/python.exe
    

    该配置强制Bazel使用指定版本的Python,避免多版本冲突导致工具链识别失败。

  • 清理缓存并修正编译命令
    先执行bazel clean清理Bazel缓存,再重新运行编译命令(补充bazel前缀并移除原命令末尾的逗号):

    bazel build -c opt --config=android_arm64 mediapipe/modules/pose_detection:*
    
  • 匹配Bazel与MediaPipe版本
    查看MediaPipe根目录下WORKSPACE文件中的bazel_version字段,确保本地安装的Bazel版本与该要求一致。版本不匹配会导致工具链逻辑不兼容,引发此类错误。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.23 19:12:13