【问题标题】:subprocess error on qpython (OSerror)qpython 上的子进程错误(OSerror)
【发布时间】:2017-03-08 23:47:44
【问题描述】:

我正在尝试通过带有子进程(python 2.7(qpython android))的套接字发送命令。 这是代码:

#reponse is my command
x = subprocess.Popen(reponse, 
         shell=True,
         stdout=subprocess.PIPE, 
         stderr=subprocess.PIPE, 
         stdin=subprocess.PIPE)
y = str(x.stdout.read() + x.stderr.read())

但是当我尝试时,我遇到了这个错误:

Traceback (most recent call last):   
File "ser.py", line 72, in <module>     
stdin=subprocess.PIPE)   
File "/QPython/QPython2-core/build/python-install/lib/python2.7/subprocess.py",
line 679, in __init__   
File "/QPython/QPython2-core/build/python-install/lib/python2.7/subprocess.py", 
line 1228, in _execute_child 
OSError: [Errno 2] No such file or directory

那么,谁能告诉我出了什么问题,以及如何解决这个问题.. 提前谢谢帮助...

【问题讨论】:

    标签: android python subprocess qpython


    【解决方案1】:

    我发现如果您指定shell=True,命令将不起作用。 我有同样的错误。

    您应该将命令及其参数用作列表;即:

    your_cmd = ['examplecmd', '-a', 'foo', '-b', 'bar']
    

    【讨论】:

      猜你喜欢
      • 2014-01-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多