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 KeyError: 'PATH' error.
A comment on this post suggests that this is because cron runs with a different environment. When I switch using env -i /bin/bash --noprofile --norc as suggested, the KeyError is raised and appears to be from os.environ["PATH"] not being set, which I can confirm.
How do I set that, and to what? Can I make this permanent for cron?
EDIT: 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 KeyError?
os.path.dirname(os.path.realpath(__file__))if that's of any help.os.environ["PATH]. My libraries are all in my user'sbinfolder.KeyErrorthough, so maybe this specific situation is helpful to others?