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

时间:2019-07-15 08:21:15

标签: python fabric

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

我尝试将env.shell更改为计算机B的“哪个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"

1 个答案:

答案 0 :(得分:0)

感谢您的解决方案。我在run()函数中使用了“ / full / path / to / python script.py”,它可以正常工作。