I have a very short Python program that runs on one of my Raspberry Pis to collect temperatures from a 1-wire sensor and write them to a database:-
#!/usr/bin/python3 # # # read temperature from 1-wire sensor and store in database with date and time # import sqlite3 import time ftxt = str(open("/sys/bus/w1/devices/28-01204e1e64c3/w1_slave").read(100)) temp = (float(ftxt[ftxt.find("t=") +2:]))/1000 # # # insert date, time and temperature into the database # tdb = sqlite3.connect("/home/chris/.cfg/share/temperature/temperature.db") cr = tdb.cursor() dt = time.strftime("%Y-%m-%d %H:%M") cr.execute("Insert INTO temperatures (DateTime, Temperature) VALUES(?, round(?, 2))", (dt, temp) ) tdb.commit() tdb.close() It's run by cron every 10 minutes. At 03:40 last night it suddenly started throwing the following error every time it ran:- Fatal Python error: initfsencoding: Unable to get the locale encoding LookupError: unknown encoding: UTF-8 Current thread 0xb6f8db40 (most recent call first): Aborted Running the program from the command line produced the same error. Restarting the Pi system has fixed the problem. What could have caused this? I certainly wasn't around at 03:40! :-) There aren't any automatic updates enabled on the system, the only thing that might have been going on was a backup as that Pi is also my 'NAS' with a big USB drive connected to it. The backups have been running without problems for more than a year. Looking at the system logs shows that a backup was started at 03:35 so I suppose that *could* have provoked something but I fail to understand how. -- Chris Green ยท -- https://mail.python.org/mailman/listinfo/python-list