Mediapipe 构建失败没有名为“numpy”的模块

问题描述

我尝试在 xcode 中构建 HandTracker 目标并出现此错误

error: An error occurred during the fetch of repository 'local_execution_config_python':
   Traceback (most recent call last):
    File "/private/var/tmp/_bazel_air/295474371363cb7bb712bb69027e5852/external/org_tensorflow/third_party/py/python_configure.bzl",line 213,column 39,in _create_local_python_repository
        numpy_include = _get_numpy_include(repository_ctx,python_bin) + "/numpy"
    File "/private/var/tmp/_bazel_air/295474371363cb7bb712bb69027e5852/external/org_tensorflow/third_party/py/python_configure.bzl",line 187,column 19,in _get_numpy_include
        return execute(
    File "/private/var/tmp/_bazel_air/295474371363cb7bb712bb69027e5852/external/org_tensorflow/third_party/remote_config/common.bzl",line 217,column 13,in execute
        fail(
Error in fail: Problem getting numpy include path.
Traceback (most recent call last):
  File "<string>",line 1,in <module>
ModuleNotFoundError: No module named 'numpy'
Is numpy installed?
error: Analysis of aspect '@tulsi//:tulsi/tulsi_aspects.bzl%tulsi_outputs_aspect of //mediapipe/examples/ios/handtrackinggpu:HandTrackingGpuApp' Failed; build aborted: Problem getting numpy include path.
Traceback (most recent call last):
  File "<string>",in <module>
ModuleNotFoundError: No module named 'numpy'
Is numpy installed?
note: Elapsed time: 12,284s
note: 0 processes.
error: Build did NOT complete successfully (4 packages loaded,7 targets configured)
<*> Running Bazel completed in 12509.306 ms
/Users/air/Documents/Mediapipe.xcodeproj/.tulsi/Scripts/bazel_build.py:569: error: Bazel build Failed with exit code 1. Please check the build log in Report Navigator (⌘9) for more information.

这里说我没有 numpy,但我是通过 pip install numpy 安装的。

pip 列表输出

Package       Version
------------- --------
absl-py       0.11.0
dataclasses   0.6
numpy         1.19.3
opencv-python 4.4.0.46
pip           20.3.3
protobuf      3.14.0
setuptools    47.1.0
six           1.15.0
wheel         0.36.2

起初,项目正常构建,但后来我不记得我做了什么,这些错误开始了。 Python 3.8.5、macOS 11.1、bazel 3.7.2

解决方法

Bazel 的目标之一是使构建可重现,因此它不依赖于特定于机器的库。

您需要使用 pip_import 定义依赖项。

,

我在使用 sudo 构建 bazel 时遇到了类似的问题!当我删除 sudo 时,一切正常。