title: python - capture pandoc error message via subprocess
body: <p>I am writing some Python code that interacts with <code>pandoc</code> via the <code>subprocess</code> module. I am, however, having trouble capturing what <code>pandoc</code> would normally print to the console whenever a command goes wrong. For example, I put this command into Terminal:</p>
  
  <pre><code>pandoc -N  --variable mainfont=Georgia --variable sansfont=Arial --variable monofont="Bitstream Vera Sans Mono" --variable fontsize=12pt --variable version=1.10 README.txt  --latex-engine=xelatex --toc -o README.pdf
  </code></pre>
  
  <p>And <code>pandoc</code> then spits out this error message:</p>
  
  <pre><code>!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  !
  ! fontspec error: "font-not-found"
  ! 
  ! The font "Bitstream Vera Sans Mono" cannot be found.
  ! 
  ! See the fontspec documentation for further information.
  ! 
  ! For immediate help type H .
  !...............................................                                                   
  l.20 ...apping=tex-ansi]{Bitstream Vera Sans Mono}  
  pandoc: Error producing PDF from TeX source
  </code></pre>
  
  <p>Now, I've tried to capture this same error message within my Python code, but to no avail. My current code looks like this:</p>
  
  <pre><code>cmd = ['pandoc', '-N', '--variable=mainfont:Georgia', '--variable=sansfont:Arial', '--variable=monofont:"Bitstream Vera Sans Mono"', '--variable=fontsize:12pt', '--variable=version:1.10', 'README.txt', '--latex-engine=xelatex', '--toc', '--output=README.pdf']
  proc = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
  print proc
  </code></pre>
  
  <p>But this only tells me that the command <code>returned non-zero exit status 43</code>. It doesn't print the full (actually informative) error message that I get in the console. </p>
  
  <p>What am I missing?</p>