i have a simple python3 Script that works when I'm running it from console:
import configparser
file = 'config_test.ini'
config = configparser.ConfigParser()
config.read(file)
for key in config['test_section']: print(key)
the called ini-file looks like this:
[test_section]
testkey1 = 5
testkey2 = 42878180
testkey3 = WR50MS10:1100012307
testkey4 = WR50MS04:1100012010
testkex5 = 192.168.200.168
and the script runs fine and returns the five keys of the ini-file.
No I configured it as a cronjob every minute (running on rasbian on Raspberry Pi) via:
* * * * * python3 /home/pi/s0/testconfig.py >> /tmp/cron_debug_log.log 2>&1
and the log looks like this:
Traceback (most recent call last):
File "/home/pi/s0/testconfig.py", line 7, in <module>
for key in config['test_section']: print(key)
File "/usr/lib/python3.2/configparser.py", line 941, in __getitem__
raise KeyError(key)
KeyError: 'test_section'
Does anyone have an idea what I did wrong Kind regards