Hướng dẫn usr/bin/env pythonr: no such file or directory windows - usr/bin/env pythonr: không có cửa sổ tệp hoặc thư mục như vậy

Lỗi này có nghĩa là Git Bash không biết Python.exe của bạn ở đâu. Nó tìm kiếm đường dẫn tìm kiếm Windows bình thường của bạn, biến môi trường

C:\> python --version
Python 2.7.2
0. Có lẽ bạn đã thất bại trong bước thứ 4 trên các hướng dẫn đã "đảm bảo Python đang làm việc trong git bash":

$ python --version
sh.exe: python: command not found

Để khắc phục điều đó, hãy nối thêm

C:\> python --version
Python 2.7.2
1 (hoặc bất cứ nơi nào bạn đã cài đặt Python) vào biến môi trường
C:\> python --version
Python 2.7.2
0 của bạn trong Windows (hướng dẫn tại đây). Bạn cần khởi động lại bash sau này để thay đổi có hiệu lực. Điều này cũng sẽ cho phép bạn chạy Python từ dấu nhắc lệnh Windows.

C:\> python --version
Python 2.7.2

Nếu bạn không muốn thay đổi biến Windows

C:\> python --version
Python 2.7.2
0 của mình hoặc cung cấp Python chỉ có sẵn cho Git Bash, bạn có thể tạo tệp
C:\> python --version
Python 2.7.2
4 trong thư mục
C:\> python --version
Python 2.7.2
5 của bạn và đặt biến ở đó:

C:\>notepad %USERPROFILE%\.bashrc

và thêm

Xuất đường dẫn =/c/python: $ đường dẫn

cho tập tin. Kịch bản đó được thực thi mỗi khi bạn bắt đầu git bash và chuẩn bị

C:\> python --version
Python 2.7.2
1 cho biến
C:\> python --version
Python 2.7.2
0 của Git Bash, khiến biến đường dẫn rộng hệ thống không bị ảnh hưởng.

Bây giờ bạn đã biết những gì phải làm, bạn có thể sử dụng phím tắt này trên bash thay thế (cộng đồng lệnh xuất vào .bashrc của bạn)

$ echo export PATH=/c/Python:\$PATH >> ~/.bashrc

Có một câu hỏi về dự án này? Đăng ký một tài khoản GitHub miễn phí để mở một vấn đề và liên hệ với người bảo trì và cộng đồng của nó. Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Chọn tên người dùng Địa chỉ EmailPassword

Bằng cách nhấp vào Đăng ký đăng ký cho GitHub, bạn đồng ý với Điều khoản dịch vụ và tuyên bố quyền riêng tư của chúng tôi. Chúng tôi thỉnh thoảng gửi cho bạn các email liên quan đến tài khoản.

Đã có trên Github? đăng nhập vào tài khoản của bạn

Tôi đang gặp phải vấn đề tương tự khi cố gắng xây dựng ví dụ về Handracking trong iOS, hoạt động tốt trước khi nâng cấp lên MacOS 12.3

Nền tảng: MacOS 12.3 Phiên bản Bazel: 3.7.2 (cũng đã thử 5.0.0 không có may mắn) Phiên bản MediaPipe: 0.8.9
Bazel version: 3.7.2 (also tried 5.0.0 with no luck)
Mediapipe Version: 0.8.9

Tôi đồng ý vấn đề liên quan đến việc loại bỏ Python 2 trong MacOS 12.3, và thực tế là không có Python trong /usr /bin. Hai lệnh xây dựng đã cố gắng sau đây dẫn đến thất bại sau, giống hệt nhau cho cả hai lệnh:

bazel build -c opt --config=ios_arm64 mediapipe/examples/ios/handtrackinggpu:HandTrackingGpuApp

bazel build -c opt --config=ios_arm64 --action_env PYTHON_BIN_PATH=$(which python3) mediapipe/examples/ios/handtrackinggpu:HandTrackingGpuApp 

ERROR: An error occurred during the fetch of repository 'local_execution_config_python':
   Traceback (most recent call last):
	File "/private/var/tmp/_bazel_jory/f9f0f6bca00c121e1c40b0977e1c780a/external/org_tensorflow/third_party/py/python_configure.bzl", line 212, column 41, in _create_local_python_repository
		python_include = _get_python_include(repository_ctx, python_bin)
	File "/private/var/tmp/_bazel_jory/f9f0f6bca00c121e1c40b0977e1c780a/external/org_tensorflow/third_party/py/python_configure.bzl", line 152, column 21, in _get_python_include
		result = execute(
	File "/private/var/tmp/_bazel_jory/f9f0f6bca00c121e1c40b0977e1c780a/external/org_tensorflow/third_party/remote_config/common.bzl", line 230, column 13, in execute
		fail(
Error in fail: Problem getting python include path.
:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
Is the Python binary path set up right? (See ./configure or PYTHON_BIN_PATH.) Is distutils installed?
ERROR: Analysis of target '//mediapipe/examples/ios/handtrackinggpu:HandTrackingGpuApp' failed; build aborted: Problem getting python include path.
:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
Is the Python binary path set up right? (See ./configure or PYTHON_BIN_PATH.) Is distutils installed?
INFO: Elapsed time: 3.406s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (39 packages loaded, 179 targets configured)

Là một sửa chữa cố gắng, tôi đã cài đặt Python 2 theo cách thủ công từ https://www.python.org/doads/release/python-2718/. Một cách riêng biệt, tôi đã thử đặt hành động-env cho python3 trong /usr /bin. Trong những trường hợp đó, hai lệnh xây dựng sau đây dẫn đến sự thất bại giống hệt nhau sau:

bazel build -c opt --config=ios_arm64 --action_env PYTHON_BIN_PATH=/usr/local/bin/python --verbose_failures mediapipe/examples/ios/handtrackinggpu:HandTrackingGpuApp 

bazel build -c opt --config=ios_arm64 --action_env PYTHON_BIN_PATH=/usr/bin/python3 --verbose_failures mediapipe/examples/ios/handtrackinggpu:HandTrackingGpuApp 

INFO: Analyzed target //mediapipe/examples/ios/handtrackinggpu:HandTrackingGpuApp (168 packages loaded, 10586 targets configured).
INFO: Found 1 target...
ERROR: /Users/jory/mediapipe/mediapipe/examples/ios/handtrackinggpu/BUILD:34:16: StoryboardCompile mediapipe/examples/ios/handtrackinggpu/HandTrackingGpuApp-intermediates/Base.lproj_storyboardc/Main.storyboardc failed (Exit 127): xctoolrunner failed: error executing command 
  (cd /private/var/tmp/_bazel_jory/f9f0f6bca00c121e1c40b0977e1c780a/execroot/mediapipe && \
  exec env - \
    APPLE_SDK_PLATFORM=iPhoneOS \
    APPLE_SDK_VERSION_OVERRIDE=15.4 \
    XCODE_VERSION_OVERRIDE=13.3.0.13E5104i \
  bazel-out/host/bin/external/build_bazel_rules_apple/tools/xctoolrunner/xctoolrunner ibtool --compilation-directory '[ABSOLUTE]bazel-out/ios_arm64-opt/bin/mediapipe/examples/ios/handtrackinggpu/HandTrackingGpuApp-intermediates/Base.lproj_storyboardc' --minimum-deployment-target 10.0 --target-device iphone --target-device ipad --module HandTrackingGpuApp '[ABSOLUTE]mediapipe/examples/ios/common/Base.lproj/Main.storyboard')
Execution platform: @local_execution_config_platform//:platform
env: python: No such file or directory
Target //mediapipe/examples/ios/handtrackinggpu:HandTrackingGpuApp failed to build
INFO: Elapsed time: 4.168s, Critical Path: 0.04s
INFO: 6 processes: 6 internal.
FAILED: Build did NOT complete successfully