title: KeyError 'PATH' when running script from cron
body: <p>I have a Python script that works when run from the normal Terminal (and from any location) but fails when running from cron, throwing a <code>KeyError: 'PATH'</code> error.</p>
  
  <p>A comment on <a href="https://stackoverflow.com/a/12534242/1167783">this post</a> suggests that this is because cron runs with a different environment. When I switch using <code>env -i /bin/bash --noprofile --norc</code> as suggested, the <code>KeyError</code> is raised and appears to be from <code>os.environ["PATH"]</code> not being set, which I can confirm.</p>
  
  <p>How do I set that, and to what? Can I make this permanent for cron?</p>
  
  <p><strong>EDIT:</strong> My question is very similar to some others, but different in that it threw a specific error from Python – I think keeping this question will help if anyone gets the same <code>KeyError</code>?</p>