I have a simple python script set to run via the crontab which keeps failing. The script utilizes the keyring package, installed through pip. I set up keyring and can run the script manually in the shell with no problem via 'python3 /home/matt/script.py'. When I test run the script in the cronitor shell (emulating what is happening when the cron job fires off), I get:
Traceback (most recent call last):
File "/home/matt/script.py", line 3, in <module>
password = keyring.get_password("system", "blahblahblah")
File "/home/matt/.local/lib/python3.9/site-packages/keyring/core.py", line 55, in get_password
return get_keyring().get_password(service_name, username)
File "/home/matt/.local/lib/python3.9/site-packages/keyring/backends/fail.py", line 25, in get_password
raise NoKeyringError(msg)
keyring.errors.NoKeyringError: No recommended backend was available. Install a recommended 3rd party backend package; or, install the keyrings.alt package if you want to use the non-recommended backends. See https://pypi.org/project/keyring for details.
After reading up on cron, I figured installing and setting up the keyring root would solve the problem, so I sudo su'd, did all the set up, and...the job still failed...
Strangely, if I run the job manually as root, it succeeds...It's just through the crontab that it fails, but isn't it the root user which executes cron jobs?
I've also tried specifying the path for keyring in the script with sys.append, but no change in the error.