title: python - how to capture errors from a ghostscript command run in a subprocess
body: <p>I am running ghostscript in a subprocess, which is working well except I don't seem to be able to capture errors.</p>
  
  <pre><code>import subprocess
  
  cmd = 'gs -dSAFER -dNOPAUSE -dBATCH -sDEVICE=jpeg -sOutputFile=img-%d.jpeg -r150 -g600x600 sample.pdf'
  p = subprocess.Popen(cmd.split(), shell=False, stderr=subprocess.PIPE)
  
  stderr = p.communicate()
  
  print stderr
  </code></pre>
  
  <p>My problem is whether the command executes correctly or no the stderr always equals:</p>
  
  <p>(None, '')</p>
  
  <p>I made a second attempt specifying both stdout and stderr</p>
  
  <pre><code>p = subprocess.Popen(slide_cmd.split(), shell=False, stdin=PIPE, stdout=PIPE, stderr=STDOUT)
  </code></pre>
  
  <p>p.stdout gives output but p.stderr still returns on None</p>