title: Python subprocess.CalledProcessError: returned non-zero exit status 2
body: <pre><code>#!/usr/bin/env python
  # encoding: utf-8
  
  import re
  import subprocess
  import time
  import json
  
  
  def get_temperatures(disks):
      sensors = subprocess.check_output([&quot;sensors&quot;])
      temperatures = {match[0]: float(match[1]) for match in re.findall(&quot;^(.*?)\:\s+\+?(.*?)°C&quot;, 
                                              sensors, re.MULTILINE)}
      for disk in disks:
          output = subprocess.check_output([&quot;smartctl&quot;, &quot;-A&quot;, disk])
          temperatures[disk] = int(re.search(&quot;Temperature.*\s(\d+)\s*(?:\([\d\s]*\)|)$&quot;, 
                                              output, re.MULTILINE).group(1))
      return temperatures
  
  
  def main():
      while True:
          print json.dumps(get_temperatures((&quot;/dev/sda2&quot;, &quot;/dev/sdb1&quot;)))
          time.sleep(20)
  
  
  if __name__ == '__main__':
      main()
  </code></pre>
  <p>This is small script to monitor temperatures in Python, using smartmontools and lm-sensors. But when i try to run it i have a error</p>
  <pre><code>subprocess.CalledProcessError: Command '['smartctl', '-A', '/dev/sda2']' returned non-zero exit status 2
  </code></pre>
  <p>But when i try this command manually in terminal they work great.</p>
  <p>Some info:</p>
  <pre><code>uname -a 
  </code></pre>
  <blockquote>
  <pre><code>Linux LME 4.0.0-040000-generic #201504121935 SMP Sun Apr 12 23:36:33 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
  </code></pre>
  </blockquote>