Python subprocess throws [Errno 2] No such file or directory, error generated only when it on a remote host

▼魔方 西西 提交于 2019-12-31 06:26:05

问题


I'm running python 2.6. I'm getting the subprocess throws [Errno 2] No such file or directory only when I run the script via ssh.

For example, if I run the script manually on the machine, there are no errors, but if I do ssh hostname script.py --host hostname it generates the error and tells me that File "/usr/lib64/python2.6/subprocess.py is missing, but that's not true as both servers have that file.

I've written the subprocess call like this:

p4 = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)

The command just contains a list.

Any ideas why it works locally, but not remotely?


回答1:


The solution for this was to simply have the command set to the absolute path, for example, instead of mke2fs, I needed /sbin/mke2fs.



来源:https://stackoverflow.com/questions/30938429/python-subprocess-throws-errno-2-no-such-file-or-directory-error-generated-on

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!