使用 Fabric 的 运行 命令在远程计算机上 运行ning python 脚本时出错

Error when running python script on remote machine using Fabric's run command

从远程机器 A,我正在尝试 运行 使用 Fabric 的 运行 函数托管在远程机器 B 上的 python 脚本。但是,出现以下错误。

我曾尝试将 env.shell 更改为计算机 B 的 "which python" 目录,但没有成功。

with cd('/opt/app/transfer_learning'):
    run("python script.py")

预期的结果是看到正在执行的脚本,它将上传一些内容到 MongoDB,我将在其中侦听更改。但是,弹出以下错误:

[3.0.40.214] run: python script.py
[3.0.40.214] out: /bin/bash: python: command not found
[3.0.40.214] out:


Fatal error: run() received nonzero return code 127 while executing!

Requested: python script.py
Executed: /bin/bash -l -c "cd /opt/app/transfer_learning >/dev/null && python script.py"

感谢 furas 提供的解决方案。我在 运行() 函数中使用了“/full/path/to/python script.py”,它起作用了。