Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/357.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python OSError:[errno2]没有这样的文件或目录_Python_Raspberry Pi - Fatal编程技术网

Python OSError:[errno2]没有这样的文件或目录

Python OSError:[errno2]没有这样的文件或目录,python,raspberry-pi,Python,Raspberry Pi,我试图从pir传感器获取信号,将其传输到web服务。当我运行此代码时 if Current_State==1 and Previous_State==0: # PIR is triggered output = subprocess.check_output(["Current_State==1 and enter code herePrevious_State==0","18"]); print " Motion detected!" # Tell the

我试图从pir传感器获取信号,将其传输到web服务。当我运行此代码时

if Current_State==1 and Previous_State==0:
  # PIR is triggered
    output =  subprocess.check_output(["Current_State==1 and enter code herePrevious_State==0","18"]);
     print "  Motion detected!"
     # Tell the Pi to run our speech script and speak the words
     # motion dtected! - anything after the .sh will be read out.
    enter code here` matches = re.search("Current_State==1 and Previous_State==0", output)
     move = int(matches.group(1))
     resultm = client.service.retrieveMove(move)
我犯了这个错误

**Traceback (most recent call last):
  File "pir_5.py", line 48, in <module>
    output =  subprocess.check_output(["Current_State==1 and Previous_State==0", "18"]);
  File "/usr/lib/python2.7/subprocess.py", line 537, in check_output
    process = Popen(stdout=PIPE, *popenargs, **kwargs)
  File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1259, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory****
**回溯(最近一次呼叫最后一次):
文件“pir_5.py”,第48行,在
输出=子进程。检查_输出([“当前_状态==1,上一个_状态==0”,“18”);
文件“/usr/lib/python2.7/subprocess.py”,第537行,在check_输出中
进程=Popen(stdout=PIPE,*popenargs,**kwargs)
文件“/usr/lib/python2.7/subprocess.py”,第679行,在__
错误读取,错误写入)
文件“/usr/lib/python2.7/subprocess.py”,第1259行,在执行子进程中
引发子对象异常
OSError:[Errno 2]没有这样的文件或目录****

子流程。checkoutput()
希望获得一个要运行的命令,以便它能够捕获输出,如Python文档中的规范示例所示:

subprocess.check_output(["echo", "Hello World!"])
正如预期的那样,这将为您提供字符串“Hello World!”\n'

您给它的命令是:

["Current_State==1 and enter code herePrevious_State==0","18"]
这不太可能是有效的

你需要真正弄清楚你想要做什么(这个问题还不清楚),然后基于此构建命令。例如,如果您想以某种方式记录(使用名为
logMe
的程序),您可以执行以下操作:

output = subprocess.check_output(["logMe","CurrState=1 and PrevState=0","18"]);

subprocess.checkoutput()
希望获得一个要运行的命令,以便它能够捕获输出,如Python文档中的规范示例所示:

subprocess.check_output(["echo", "Hello World!"])
正如预期的那样,这将为您提供字符串“Hello World!”\n'

您给它的命令是:

["Current_State==1 and enter code herePrevious_State==0","18"]
这不太可能是有效的

你需要真正弄清楚你想要做什么(这个问题还不清楚),然后基于此构建命令。例如,如果您想以某种方式记录(使用名为
logMe
的程序),您可以执行以下操作:

output = subprocess.check_output(["logMe","CurrState=1 and PrevState=0","18"]);

您需要在列表的第一个参数中为subprocess.check_output指定一个shell命令。然后第二个、第三个、任意元素是shell命令的第一个、第二个、任意参数

当前_State==1并在此处输入代码上一个_State==0不是shell命令

/bin/是真的

普华永道是

echo foo是


ls/tmp是。

您需要在列表的第一个参数中为subprocess.check\u output指定一个shell命令。然后第二个、第三个、任意元素是shell命令的第一个、第二个、任意参数

当前_State==1并在此处输入代码上一个_State==0不是shell命令

/bin/是真的

普华永道是

echo foo是


ls/tmp是。

请修改您的问题,以便更清楚地了解您需要的帮助。这里没有什么细节可以帮助你解决具体问题,因此你不太可能得到有用的答案。它可能有助于显示一些额外的上下文,例如--您在哪里定义
子流程
?@ProgrammerDan:
子流程
是一个用于运行、呃、子流程的模块,我想:-)它不是您定义的变量。@paxdiablo:)哈哈,很自然。我很高兴这个问题对你来说(相对)清楚!请修改您的问题,以便更清楚地了解您需要的帮助。这里没有什么细节可以帮助你解决具体问题,因此你不太可能得到有用的答案。它可能有助于显示一些额外的上下文,例如--您在哪里定义
子流程
?@ProgrammerDan:
子流程
是一个用于运行、呃、子流程的模块,我想:-)它不是您定义的变量。@paxdiablo:)哈哈,很自然。我很高兴这个问题对你来说(相对)清楚!我想将接收到的数据通过webservice@user3440694,然后您需要从命令行确定执行该操作的命令,然后使用
check\u output()
执行该命令。我不知道该命令是什么,但我相当确定您当前拥有的是不正确的。我希望通过发送接收到的数据到数据库webservice@user3440694,然后您需要从命令行确定执行该操作的命令,然后使用
check\u output()
执行该命令。我不知道该命令是什么,但我相当确定您当前拥有的是不正确的。