title: Subprocess command shows FileNotFoundError: [Errno 2] No such file or directory
body: <p>I'm trying to run shell commands using python by using subprocess module in the below code, but I don't why my script is throwing an error like below. Can someone help me what I'm missing?</p>
  <pre><code>Traceback (most recent call last):
    File &quot;/Scripts/test_file.py&quot;, line 6, in &lt;module&gt;
      p2 = subprocess.Popen('sed s\'/&amp;quot;/ /g\'', stdin=p1.stdout, stdout=subprocess.PIPE)
    File &quot;/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/subprocess.py&quot;, line 854, in __init__
      self._execute_child(args, executable, preexec_fn, close_fds,
    File &quot;/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/subprocess.py&quot;, line 1702, in _execute_child
      raise child_exception_type(errno_num, err_msg, err_filename)
  FileNotFoundError: [Errno 2] No such file or directory: &quot;sed s'/&amp;quot;/ /g'&quot;`
  </code></pre>
  <hr />
  <pre><code>import subprocess
  #output3.txt='/Users/boggulv/Desktop/output3.txt'
  p1 = subprocess.Popen( ['cat', 'output3.txt'], stdout=subprocess.PIPE)
  print(p1)
  p2 = subprocess.Popen('sed s\'/&amp;quot;/ /g\'', stdin=p1.stdout, stdout=subprocess.PIPE)
  p3 = subprocess.Popen('grep &quot;sO&quot;', stdin=p2.stdout,stdout=subprocess.PIPE)
  p4 = subprocess.Popen('grep -v &quot;get&quot;', stdin=p3.stdout, stdout=subprocess.PIPE)
  p5 = subprocess.Popen('cut -d \',\' -f2', stdin=p4.stdout, stdout=subprocess.PIPE)
  p6 = subprocess.Popen('sed \'s/&quot;//g\'', stdin=p5.stdout, stdout=subprocess.PIPE)
  p7 = subprocess.Popen('sort', stdin=p6.stdout, stdout=subprocess.PIPE)
  p8 = subprocess.Popen('sort', stdin=p8.stdout, stdout=subprocess.PIPE)
  p9 = subprocess.Popen('uniq -c', stdin=p8.stdout, stdout=subprocess.PIPE)
  p0 = subprocess.Popen('sort -nr', stdin=p9.stdout, stdout=subprocess.PIPE)
  print(p01.communicate())
  </code></pre>
  <p>Tried now changing to lists.</p>
  <pre><code>p2 = subprocess.Popen('sed \'s/&amp;quot;/ /g\'', stdin=p1.stdout, stdout=subprocess.PIPE, shell=True)
  p3 = subprocess.Popen(['grep','&quot;shipOption&quot;'], stdin=p2.stdout,stdout=subprocess.PIPE,shell = True)
  p4 = subprocess.Popen(['grep','-v', '&quot;getShipMethod&quot;'], stdin=p3.stdout, stdout=subprocess.PIPE,shell = True)
  p5 = subprocess.Popen(['cut','-d','\',\'', '-f2'], stdin=p4.stdout, stdout=subprocess.PIPE,shell = True)
  p6 = subprocess.Popen(['sed','\'s/&quot;//g\''],stdin=p5.stdout, stdout=subprocess.PIPE,shell = True)
  p7 = subprocess.Popen(['sort'], stdin=p6.stdout, stdout=subprocess.PIPE,shell = True)
  p8 = subprocess.Popen(['uniq', '-c'], stdin=p7.stdout, stdout=subprocess.PIPE,shell = True)
  p9 = subprocess.Popen(['sort', '-nr'], stdin=p8.stdout, stdout=subprocess.PIPE,shell = True)
  p0 = subprocess.Popen(['head', '-10'], stdin=p9.stdout, stdout=subprocess.PIPE,shell = True)```
  
  New Error:
  
  `usage: grep [-abcdDEFGHhIiJLlMmnOopqRSsUVvwXxZz] [-A num] [-B num] [-C[num]]
          [-e pattern] [-f file] [--binary-files=value] [--color=when]
          [--context[=num]] [--directories=action] [--label] [--line-buffered]
          [--null] [pattern] [file ...]
  usage: grep [-abcdDEFGHhIiJLlMmnOopqRSsUVvwXxZz] [-A num] [-B num] [-C[num]]
          [-e pattern] [-f file] [--binary-files=value] [--color=when]
          [--context[=num]] [--directories=action] [--label] [--line-buffered]
          [--null] [pattern] [file ...]
  usage: cut -b list [-n] [file ...]
         cut -c list [file ...]
         cut -f list [-s] [-w | -d delim] [file ...]
  (b'', None)
  cat: stdin: Input/output error`
  </code></pre>