简体   繁体   English

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

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

From a remote machine A, I am trying to run a python script hosted on a remote machine B using Fabric's run function. 我正在尝试从远程计算机A使用Fabric的run函数运行在远程计算机B上托管的python脚本。 However, the following error shows up. 但是,出现以下错误。

I have tried changing env.shell to machine B's "which python" directory but it did not work. 我尝试将env.shell更改为计算机B的“哪个python”目录,但是它不起作用。

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

The expected result is to see the script being executed which will upload something to MongoDB in which I will listen for changes. 预期结果是看到正在执行的脚本,该脚本会将某些内容上传到MongoDB,我将在其中侦听更改。 However, the following error pops up: 但是,将弹出以下错误:

[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"

Thank you furas for the solution. 谢谢furas提供的解决方案。 I used "/full/path/to/python script.py" instead in the run() function and it worked. 我在run()函数中使用了“ / full / path / to / python script.py”,它可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM