tflite-support icon indicating copy to clipboard operation
tflite-support copied to clipboard

ios TensorFlowLiteTaskVision build error (env: python: No such file or directory)

Open physxP opened this issue 3 years ago • 7 comments

I am having build issues on MacOs 12.3. The issue is directly related to bazel and changes in MacOS. build script:

FRAMEWORK_NAME=TensorFlowLiteTaskVision DEST_DIR=iosbuild 
./tensorflow_lite_support/tools/ci_build/builds/build_ios_framework.sh

Error

ERROR: /Users/tj/projects/edgestore/ModelsAPI/inference/tfliteframework/task/tflite-support/tensorflow_lite_support/ios/BUILD:69:21: Bundling Preprocessed_TensorFlowLiteTaskVisionC_framework failed: (Exit 127): bundletool failed: error executing command 
  (cd /private/var/tmp/_bazel_tj/5d20e619fbfca68099aa0f179b25fe42/execroot/org_tensorflow_lite_support && \
  exec env - \
  bazel-out/host/bin/external/build_bazel_rules_apple/tools/bundletool/bundletool bazel-out/applebin_ios-ios_arm64-opt-ST-02f4a105b518/bin/tensorflow_lite_support/ios/Preprocessed_TensorFlowLiteTaskVisionC_framework-intermediates/bundletool_control.json)
Execution platform: @local_execution_config_platform//:platform
env: python: No such file or directory
Target //tensorflow_lite_support/ios:TensorFlowLiteTaskVisionC_framework failed to build
INFO: Elapsed time: 0.179s, Critical Path: 0.01s
INFO: 2 processes: 2 internal.

I already have python2 and python3 and both binary directories are in PATH variable. What I understand from my research the problem is that Apple removed python 2 and there is no /usr/bin/python binary and no way to add it there. This causes this particular error in bazel versions < 5.0.0. (similar error for reference).

Is it possible to fix this issue and if not can someone please point me to prebuilt binaries?

physxP avatar Apr 18 '22 00:04 physxP

Try if it works by configuring the Python bin path explicitly, such

PYTHON_BIN_PATH=$(which python3)
export PYTHON_BIN_PATH

lu-wang-g avatar Apr 18 '22 21:04 lu-wang-g

@priankakariatyml FYI

khanhlvg avatar Apr 19 '22 14:04 khanhlvg

Try if it works by configuring the Python bin path explicitly, such

PYTHON_BIN_PATH=$(which python3)
export PYTHON_BIN_PATH

Sorry, same issue

physxP avatar Apr 19 '22 16:04 physxP

Then try if the following works for you:

PYTHON_BIN_PATH=$(which python3)
export PYTHON_BIN_PATH
sudo rm -f /usr/bin/python3
sudo ln -s "${PYTHON_BIN_PATH}" /usr/bin/python3

lu-wang-g avatar Apr 23 '22 23:04 lu-wang-g

The issue is that by default /usr/bin is read only. I however circumvented it recently by following a few guides but it required turning off many security features like encryption and filevault. Then copying /usr/bin/python3 to /usr/bin/python made it finally work but it is quite a hassle.

physxP avatar Apr 27 '22 19:04 physxP

hey @physxP Can you please provide links to the guides you used to make /usr/bin writable. Thanks!

OlegDeg avatar May 24 '22 16:05 OlegDeg

hey @physxP Can you please provide links to the guides you used to make /usr/bin writable. Thanks!

As far as I remember no guide worked directly on Mac m1. I had to figure out equivalent commands on M1. I mostly entered the commands from the following script: https://github.com/fxgst/writeable_root/blob/main/writeable_root.c Also make sure to follow the prerequisites. I think the "sudo bless" command has to be changed to work on M1. Sorry I don't remember exact changes as it has been a while.

physxP avatar May 24 '22 17:05 physxP