Windows bazel says python is not an executable when building tflite
Hi @turgut-baba could you please run the steps in the link below before running configure.py and let us know if you are still getting the errors?
https://github.com/tensorflow/docs/blob/master/site/en/install/source_windows.md#optional-environmental-variable-set-up @turgut-baba,
Could you please confirm whether you are trying to install from the build from source for the Windows. Also you are trying to install tensorflow v2.12 with the Bazel 6.1.1 which is not compatible. 

For tensorflow v2.12 the compatible Bazel version is 5.3.0. Please take a look at the official tested build configurations
from [here](https://www.tensorflow.org/install/source_windows#gpu) and Could you try `bazel clean --expunge` followed by bazel sync

![Screenshot 2023-05-03 9 47 32 AM](https://user-images.githubusercontent.com/81610181/235832083-9f7a8c19-104b-474c-9e3e-18eeb835679c.png)

Thank you! @tilakrayal , @mraunak  I've set the environment variables and changed my bazel version to 5.3.0 but the error remains. The same message. The only different thing I've noticed is that, naturally, the path is different but the error is still the same: 
```
ERROR: An error occurred during the fetch of repository 'local_config_python':
   Traceback (most recent call last):
        File "C:/users/asus/desktop/tensorflow/third_party/py/python_configure.bzl", line 271, column 40, in _python_autoconf_impl
                _create_local_python_repository(repository_ctx)
        File "C:/users/asus/desktop/tensorflow/third_party/py/python_configure.bzl", line 212, column 22, in _create_local_python_repository
                _check_python_bin(repository_ctx, python_bin)
        File "C:/users/asus/desktop/tensorflow/third_party/py/python_configure.bzl", line 145, column 25, in _check_python_bin
                auto_config_fail("--define %s='%s' is not executable. Is it the python binary?" % (
        File "C:/users/asus/desktop/tensorflow/third_party/remote_config/common.bzl", line 12, column 9, in auto_config_fail
                fail("%sConfiguration Error:%s %s\n" % (red, no_color, msg))
Error in fail: Configuration Error: --define PYTHON_BIN_PATH='C:/Users/Asus/Desktop/tensorflow/tflite-venv/Scripts/python.exe' is not executable. Is it the python binary?
ERROR: C:/users/asus/desktop/tensorflow/WORKSPACE:15:14: fetching python_configure rule //external:local_config_python: Traceback (most recent call last):
        File "C:/users/asus/desktop/tensorflow/third_party/py/python_configure.bzl", line 271, column 40, in _python_autoconf_impl
                _create_local_python_repository(repository_ctx)
        File "C:/users/asus/desktop/tensorflow/third_party/py/python_configure.bzl", line 212, column 22, in _create_local_python_repository
                _check_python_bin(repository_ctx, python_bin)
        File "C:/users/asus/desktop/tensorflow/third_party/py/python_configure.bzl", line 145, column 25, in _check_python_bin
                auto_config_fail("--define %s='%s' is not executable. Is it the python binary?" % (
        File "C:/users/asus/desktop/tensorflow/third_party/remote_config/common.bzl", line 12, column 9, in auto_config_fail
                fail("%sConfiguration Error:%s %s\n" % (red, no_color, msg))
Error in fail: Configuration Error: --define PYTHON_BIN_PATH='C:/Users/Asus/Desktop/tensorflow/tflite-venv/Scripts/python.exe' is not executable. Is it the python binary?
INFO: Repository go_sdk instantiated at:
  C:/users/asus/desktop/tensorflow/WORKSPACE:23:14: in <toplevel>
  C:/users/asus/desktop/tensorflow/tensorflow/workspace0.bzl:134:20: in workspace
  C:/users/asus/_bazel_asus/ddsftcyc/external/com_github_grpc_grpc/bazel/grpc_extra_deps.bzl:36:27: in grpc_extra_deps
  C:/users/asus/_bazel_asus/ddsftcyc/external/io_bazel_rules_go/go/private/sdk.bzl:431:28: in go_register_toolchains
  C:/users/asus/_bazel_asus/ddsftcyc/external/io_bazel_rules_go/go/private/sdk.bzl:130:21: in go_download_sdk
Repository rule _go_download_sdk defined at:
  C:/users/asus/_bazel_asus/ddsftcyc/external/io_bazel_rules_go/go/private/sdk.bzl:117:35: in <toplevel>
ERROR: Analysis of target '//tensorflow/lite:tensorflowlite' failed; build aborted: Configuration Error: --define PYTHON_BIN_PATH='C:/Users/Asus/Desktop/tensorflow/tflite-venv/Scripts/python.exe' is not executable. Is it the python binary?
INFO: Elapsed time: 2.029s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (33 packages loaded, 15 targets configured)
``` Hi @turgut-baba, can you please try to run "bazel clean --expunge" to make sure old bazel files are deleted? and then run the build command again.
If you still get an error try the command in the image to make sure 'location to python.exe' is recognized as executable

![image](https://github.com/tensorflow/tensorflow/assets/83710963/418fd9b4-9f7f-4b68-8265-576ff4413cd5)

If it still does not work, please follow the steps below
[steps.txt](https://github.com/tensorflow/tensorflow/files/11521798/steps.txt)

 @mraunak Thanks, but now I'm getting this error:
```
Repository rule local_python_configure defined at:
  C:/users/asus/desktop/tensorflow/third_party/py/python_configure.bzl:279:41: in <toplevel>
ERROR: An error occurred during the fetch of repository 'local_execution_config_python':
   Traceback (most recent call last):
        File "C:/users/asus/desktop/tensorflow/third_party/py/python_configure.bzl", line 216, column 39, in _create_local_python_repository
                numpy_include = _get_numpy_include(repository_ctx, python_bin) + "/numpy"
        File "C:/users/asus/desktop/tensorflow/third_party/py/python_configure.bzl", line 190, column 19, in _get_numpy_include
                return execute(
        File "C:/users/asus/desktop/tensorflow/third_party/remote_config/common.bzl", line 230, 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: C:/users/asus/desktop/tensorflow/WORKSPACE:15:14: fetching local_python_configure rule //external:local_execution_config_python: Traceback (most recent call last):
        File "C:/users/asus/desktop/tensorflow/third_party/py/python_configure.bzl", line 216, column 39, in _create_local_python_repository
                numpy_include = _get_numpy_include(repository_ctx, python_bin) + "/numpy"
        File "C:/users/asus/desktop/tensorflow/third_party/py/python_configure.bzl", line 190, column 19, in _get_numpy_include
                return execute(
        File "C:/users/asus/desktop/tensorflow/third_party/remote_config/common.bzl", line 230, 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?
INFO: Repository go_sdk instantiated at:
  C:/users/asus/desktop/tensorflow/WORKSPACE:23:14: in <toplevel>
  C:/users/asus/desktop/tensorflow/tensorflow/workspace0.bzl:134:20: in workspace
  C:/users/asus/_bazel_asus/ddsftcyc/external/com_github_grpc_grpc/bazel/grpc_extra_deps.bzl:36:27: in grpc_extra_deps
  C:/users/asus/_bazel_asus/ddsftcyc/external/io_bazel_rules_go/go/private/sdk.bzl:431:28: in go_register_toolchains
  C:/users/asus/_bazel_asus/ddsftcyc/external/io_bazel_rules_go/go/private/sdk.bzl:130:21: in go_download_sdk
Repository rule _go_download_sdk defined at:
  C:/users/asus/_bazel_asus/ddsftcyc/external/io_bazel_rules_go/go/private/sdk.bzl:117:35: in <toplevel>
ERROR: Analysis of target '//tensorflow/lite:tensorflowlite' failed; build aborted: Problem getting numpy include path.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'numpy'
Is numpy installed?
INFO: Elapsed time: 1.232s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets configured)
``` I've deleted python311 from my system and it solved the program. Now I'm getting this error:
```
ERROR: C:/users/asus/desktop/tensorflow/tensorflow/lite/schema/BUILD:184:22: Generating flatbuffer files for conversion_metadata_fbs_srcs: //tensorflow/lite/schema:conversion_metadata_fbs_srcs failed: (Exit -1): bash.exe failed: error executing command
  cd /d C:/users/asus/_bazel_asus/ddsftcyc/execroot/org_tensorflow
  SET PATH=C:\msys64\usr\bin;C:\msys64\bin;C:\Windows;C:\Windows\System32;C:\Windows\System32\WindowsPowerShell\v1.0;c:\Tools\Bazel;C:\Users\Asus\venv39_new\Scripts;C:\Python39\Scripts\;C:\Users\Asus\Desktop\Bazel_compiler
    SET PYTHON_BIN_PATH=C:/Users/Asus/venv39_new/Scripts/python.exe
    SET PYTHON_LIB_PATH=C:/Users/Asus/venv39_new/lib/site-packages
    SET RUNFILES_MANIFEST_ONLY=1
    SET TF2_BEHAVIOR=1
  C:\msys64\usr\bin\bash.exe -c source external/bazel_tools/tools/genrule/genrule-setup.sh; for f in tensorflow/lite/schema/conversion_metadata.fbs; do bazel-out/x64_windows-opt/bin/external/flatbuffers/flatc.exe --no-union-value-namespacing --gen-object-api  -c -o bazel-out/x64_windows-opt/bin/tensorflow/lite/schema $f; done
# Configuration: 69f9c37d88669b53b8f73db2aad31626990e264ca81cbe6069ba71a8f673143d
# Execution platform: @local_execution_config_platform//:platform
Action failed to execute: java.io.IOException: ERROR: src/main/native/windows/process.cc(202): CreateProcessW("C:\msys64\usr\bin\bash.exe" -c "source external/bazel_tools/tools/genrule/genrule-setup.sh; for f in tensorflow/lite/schema/conversion_metadata.fbs; do bazel-out/x64_windows-opt/bin/external/flatbuffers/flatc.exe --no-union-value-namespacing --gen-object-api  -c -o bazel-out/x64_windows-opt/bin/tensorflow/lite/schema $f; done"): The system cannot find the file specified.
 (error: 2)
Target //tensorflow/lite:tensorflowlite failed to build
INFO: Elapsed time: 188.351s, Critical Path: 23.46s
INFO: 341 processes: 158 internal, 183 local.
FAILED: Build did NOT complete successfully
``` Hi @turgut-baba, please set the Java path as mentioned below. Add JAVA_HOME in the environmental variables

set JAVA_HOME = C:\Program Files\Eclipse Adoptium\jdk-17.0.4.101-hotspot 

If you still get an issue, run bazel clean --expunge command to clear bazel cache and re-rerun the build command.

 This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you. This issue was closed because it has been inactive for 7 days since being marked as stale. Please reopen if you'd like to work on this further. Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/60441">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/60441">No</a>

Please go to Stack Overflow for help and support:

https://stackoverflow.com/questions/tagged/tensorflow

If you open a GitHub issue, here is our policy:

1.  It must be a bug, a feature request, or a significant problem with the
    documentation (for small docs fixes please send a PR instead).
2.  The form below must be filled out.
3.  It shouldn't be a TensorBoard issue. Those go
    [here](https://github.com/tensorflow/tensorboard/issues).

**Here's why we have that policy**: TensorFlow developers respond to issues. We want to focus on work that benefits the whole community, e.g., fixing bugs and adding features. Support only helps individuals. GitHub also notifies thousands of people when issues are filed. We want them to see you communicating an interesting problem, rather than being redirected to Stack Overflow.

------------------------

### System information

-   Trying to build TFLite
-  Windows 10
-   Windows Asus machine
-  source
-  r2.12
-   python 3.11.2
-   bazel 6.1.1
-   windows compiler
-   **CUDA/cuDNN version**: ---
-   Geforce GTX 960m
-  bazel build -c opt //tensorflow/lite:tensorflowlite


I'm trying to build c++ tflite for windows using bazel by following the [official documentation](https://www.tensorflow.org/install/source_windows). So far I've installed everything it want's me to and added them to PATH. Then I cloned the github repo and checked out to r2.12 branch.

Then I ran python ./configure.py and selected default for everything (said yes to override eigen strong inline). When doing so it declared that my python is located on C:\Users\Asus\AppData\Local\Programs\Python\Python311\python.exe.

After that running bazel build -c opt //tensorflow/lite:tensorflowlite on the directory where I've cloned tensorflow in cmd casuses this error:

Starting local Bazel server and connecting to it...
INFO: Options provided by the client:
  Inherited 'common' options: --isatty=1 --terminal_columns=117
INFO: Reading rc options for 'build' from c:\users\asus\desktop\tensorflow\.bazelrc:
  Inherited 'common' options: --experimental_repo_remote_exec
INFO: Options provided by the client:
  'build' options: --python_path=C:/Users/Asus/AppData/Local/Programs/Python/Python311/python.exe
INFO: Reading rc options for 'build' from c:\users\asus\desktop\tensorflow\.bazelrc:
  'build' options: --define framework_shared_object=true --define tsl_protobuf_header_only=true --define=use_fast_cpp_protos=true --define=allow_oversize_protos=true --spawn_strategy=standalone -c opt --announce_rc --define=grpc_no_ares=true --noincompatible_remove_legacy_whole_archive --enable_platform_specific_config --define=with_xla_support=true --config=short_logs --config=v2 --define=no_aws_support=true --define=no_hdfs_support=true --experimental_cc_shared_library --experimental_link_static_libraries_once=false --incompatible_enforce_config_setting_visibility
INFO: Reading rc options for 'build' from c:\users\asus\desktop\tensorflow\.tf_configure.bazelrc:
  'build' options: --action_env PYTHON_BIN_PATH=C:/Users/Asus/AppData/Local/Programs/Python/Python311/python.exe --action_env PYTHON_LIB_PATH=C:/Users/Asus/AppData/Local/Programs/Python/Python311/Lib/site-packages --python_path=C:/Users/Asus/AppData/Local/Programs/Python/Python311/python.exe --copt=/d2ReducedOptimizeHugeFunctions --host_copt=/d2ReducedOptimizeHugeFunctions --define=override_eigen_strong_inline=true
INFO: Reading rc options for 'build' from c:\users\asus\desktop\tensorflow\.bazelrc:
  'build' options: --deleted_packages=tensorflow/compiler/mlir/tfrt,tensorflow/compiler/mlir/tfrt/benchmarks,tensorflow/compiler/mlir/tfrt/jit/python_binding,tensorflow/compiler/mlir/tfrt/jit/transforms,tensorflow/compiler/mlir/tfrt/python_tests,tensorflow/compiler/mlir/tfrt/tests,tensorflow/compiler/mlir/tfrt/tests/ir,tensorflow/compiler/mlir/tfrt/tests/analysis,tensorflow/compiler/mlir/tfrt/tests/jit,tensorflow/compiler/mlir/tfrt/tests/lhlo_to_tfrt,tensorflow/compiler/mlir/tfrt/tests/lhlo_to_jitrt,tensorflow/compiler/mlir/tfrt/tests/tf_to_corert,tensorflow/compiler/mlir/tfrt/tests/tf_to_tfrt_data,tensorflow/compiler/mlir/tfrt/tests/saved_model,tensorflow/compiler/mlir/tfrt/transforms/lhlo_gpu_to_tfrt_gpu,tensorflow/core/runtime_fallback,tensorflow/core/runtime_fallback/conversion,tensorflow/core/runtime_fallback/kernel,tensorflow/core/runtime_fallback/opdefs,tensorflow/core/runtime_fallback/runtime,tensorflow/core/runtime_fallback/util,tensorflow/core/tfrt/eager,tensorflow/core/tfrt/eager/backends/cpu,tensorflow/core/tfrt/eager/backends/gpu,tensorflow/core/tfrt/eager/core_runtime,tensorflow/core/tfrt/eager/cpp_tests/core_runtime,tensorflow/core/tfrt/gpu,tensorflow/core/tfrt/run_handler_thread_pool,tensorflow/core/tfrt/runtime,tensorflow/core/tfrt/saved_model,tensorflow/core/tfrt/graph_executor,tensorflow/core/tfrt/saved_model/tests,tensorflow/core/tfrt/tpu,tensorflow/core/tfrt/utils
INFO: Found applicable config definition build:short_logs in file c:\users\asus\desktop\tensorflow\.bazelrc: --output_filter=DONT_MATCH_ANYTHING
INFO: Found applicable config definition build:v2 in file c:\users\asus\desktop\tensorflow\.bazelrc: --define=tf_api_version=2 --action_env=TF2_BEHAVIOR=1
INFO: Found applicable config definition build:windows in file c:\users\asus\desktop\tensorflow\.bazelrc: --copt=/W0 --host_copt=/W0 --copt=/Zc:__cplusplus --host_copt=/Zc:__cplusplus --copt=/D_USE_MATH_DEFINES --host_copt=/D_USE_MATH_DEFINES --features=compiler_param_file --copt=/d2ReducedOptimizeHugeFunctions --host_copt=/d2ReducedOptimizeHugeFunctions --cxxopt=/std:c++17 --host_cxxopt=/std:c++17 --config=monolithic --copt=-DWIN32_LEAN_AND_MEAN --host_copt=-DWIN32_LEAN_AND_MEAN --copt=-DNOGDI --host_copt=-DNOGDI --copt=/Zc:preprocessor --host_copt=/Zc:preprocessor --linkopt=/DEBUG --host_linkopt=/DEBUG --linkopt=/OPT:REF --host_linkopt=/OPT:REF --linkopt=/OPT:ICF --host_linkopt=/OPT:ICF --verbose_failures --features=compiler_param_file --distinct_host_configuration=false
INFO: Found applicable config definition build:monolithic in file c:\users\asus\desktop\tensorflow\.bazelrc: --define framework_shared_object=false --define tsl_protobuf_header_only=false --experimental_link_static_libraries_once=false
INFO: Repository local_config_python instantiated at:
  C:/users/asus/desktop/tensorflow/WORKSPACE:15:14: in <toplevel>
  C:/users/asus/desktop/tensorflow/tensorflow/workspace2.bzl:957:19: in workspace
  C:/users/asus/desktop/tensorflow/tensorflow/workspace2.bzl:104:21: in _tf_toolchains
Repository rule python_configure defined at:
  C:/users/asus/desktop/tensorflow/third_party/py/python_configure.bzl:298:35: in <toplevel>
ERROR: An error occurred during the fetch of repository 'local_config_python':
   Traceback (most recent call last):
        File "C:/users/asus/desktop/tensorflow/third_party/py/python_configure.bzl", line 271, column 40, in _python_autoconf_impl
                _create_local_python_repository(repository_ctx)
        File "C:/users/asus/desktop/tensorflow/third_party/py/python_configure.bzl", line 212, column 22, in _create_local_python_repository
                _check_python_bin(repository_ctx, python_bin)
        File "C:/users/asus/desktop/tensorflow/third_party/py/python_configure.bzl", line 145, column 25, in _check_python_bin
                auto_config_fail("--define %s='%s' is not executable. Is it the python binary?" % (
        File "C:/users/asus/desktop/tensorflow/third_party/remote_config/common.bzl", line 12, column 9, in auto_config_fail
                fail("%sConfiguration Error:%s %s\n" % (red, no_color, msg))
Error in fail: Configuration Error: --define PYTHON_BIN_PATH='C:/Users/Asus/AppData/Local/Programs/Python/Python311/python.exe' is not executable. Is it the python binary?
ERROR: C:/users/asus/desktop/tensorflow/WORKSPACE:15:14: fetching python_configure rule //external:local_config_python: Traceback (most recent call last):
        File "C:/users/asus/desktop/tensorflow/third_party/py/python_configure.bzl", line 271, column 40, in _python_autoconf_impl
                _create_local_python_repository(repository_ctx)
        File "C:/users/asus/desktop/tensorflow/third_party/py/python_configure.bzl", line 212, column 22, in _create_local_python_repository
                _check_python_bin(repository_ctx, python_bin)
        File "C:/users/asus/desktop/tensorflow/third_party/py/python_configure.bzl", line 145, column 25, in _check_python_bin
                auto_config_fail("--define %s='%s' is not executable. Is it the python binary?" % (
        File "C:/users/asus/desktop/tensorflow/third_party/remote_config/common.bzl", line 12, column 9, in auto_config_fail
                fail("%sConfiguration Error:%s %s\n" % (red, no_color, msg))
Error in fail: Configuration Error: --define PYTHON_BIN_PATH='C:/Users/Asus/AppData/Local/Programs/Python/Python311/python.exe' is not executable. Is it the python binary?
INFO: Repository local_execution_config_python instantiated at:
  C:/users/asus/desktop/tensorflow/WORKSPACE:15:14: in <toplevel>
  C:/users/asus/desktop/tensorflow/tensorflow/workspace2.bzl:957:19: in workspace
  C:/users/asus/desktop/tensorflow/tensorflow/workspace2.bzl:94:27: in _tf_toolchains
  C:/users/asus/desktop/tensorflow/tensorflow/tools/toolchains/remote_config/configs.bzl:6:28: in initialize_rbe_configs
  C:/users/asus/desktop/tensorflow/tensorflow/tools/toolchains/remote_config/rbe_config.bzl:158:27: in _tensorflow_local_config
Repository rule local_python_configure defined at:
  C:/users/asus/desktop/tensorflow/third_party/py/python_configure.bzl:279:41: in <toplevel>
INFO: Repository go_sdk instantiated at:
  C:/users/asus/desktop/tensorflow/WORKSPACE:23:14: in <toplevel>
  C:/users/asus/desktop/tensorflow/tensorflow/workspace0.bzl:134:20: in workspace
  C:/users/asus/_bazel_asus/ddsftcyc/external/com_github_grpc_grpc/bazel/grpc_extra_deps.bzl:36:27: in grpc_extra_deps
  C:/users/asus/_bazel_asus/ddsftcyc/external/io_bazel_rules_go/go/private/sdk.bzl:431:28: in go_register_toolchains
  C:/users/asus/_bazel_asus/ddsftcyc/external/io_bazel_rules_go/go/private/sdk.bzl:130:21: in go_download_sdk
Repository rule _go_download_sdk defined at:
  C:/users/asus/_bazel_asus/ddsftcyc/external/io_bazel_rules_go/go/private/sdk.bzl:117:35: in <toplevel>
ERROR: Analysis of target '//tensorflow/lite:tensorflowlite' failed; build aborted: Configuration Error: --define PYTHON_BIN_PATH='C:/Users/Asus/AppData/Local/Programs/Python/Python311/python.exe' is not executable. Is it the python binary?
INFO: Elapsed time: 224.163s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (32 packages loaded, 15 targets configured)
Looking at the main error part of this output : ERROR: Analysis of target '//tensorflow/lite:tensorflowlite' failed; build aborted: Configuration Error: --define PYTHON_BIN_PATH='C:/Users/Asus/AppData/Local/Programs/Python/Python311/python.exe' is not executable. Is it the python binary?

I checked whether python was there or not, it indeed is. Simply running C:/Users/Asus/AppData/Local/Programs/Python/Python311/python.exe in cmd indeed opens python.

So I checked the internet for some solutions, I've removed the "python installers" from my system, added python to PATH, tried the same steps with tensorflow source zip instead of cloning it, nothing works.

Some people suggested chaning some stuff inside the py directory of tensorflow but it didn't work aswell.

Why is this happening? What causes bazel to not see python even though it's there? How can I fix this and get a build with windows?
