I am working on a data acquisition project where I am sending a bunch of sensor data to the cloud. Here is a small snippet from my code:
#!/usr/bin/python3 # coding: utf-8 import ctypes from systemd import journal . . .#Rest of the code . journal.send( channel = 'sensor', priority = journal.Priority.INFO, messageid = "%d" % (seq_num), timestamp = "%s" % (CurrentTimestamp), tdiff = "%s" % (dt), acc_x="%f" % (cax), acc_y="%f" % (cay), acc_z="%f" % (caz), gyr_x="%f" % (cgx), gyr_y="%f" % (cgy), gyr_z="%f" % (cgz), horn = "%d" % (GPIO.input(hornpin)), brake = "%d" % (GPIO.input(brakepin)), rpm = "%d" % (GPIO.input(rpmpin)), lux = "%f" % (lux), temperature_batterypack = "%d" % (temperature_batterypack), temperature_ambientair = "%d" % (temperature_ambientair), temperature_scooterbody = "%d" % (temperature_scooterbody), )
I have designed my own board using the public schematics of Raspberry Pi Compute module 3. The OS that I am using is the latest version of Raspbian Stretch Lite (June 2018 release). I am trying to autostart the code at boot by adding the following line in /etc/rc.local before exit 0:
sudo python3 /home/pi/test_scripts/cloud_test.py &
and I get the following error:
AttributeError: module 'systemd.journal' has no attribute 'Priority'
I even tried autostarting using systemd (so I created a service file) and when I check the status of the service file, it gives me the same exact error. Whereas, if I don't do auto start and manually run the code on the command prompt as:
$ python3 cloud_test.py
the code runs correctly and sends data to the cloud and I can see all the data on a website. This means all modules and python packages are correctly installed and I do not get any error. I also made by python script executable by using sudo chmod +x cloud_test.py and have also included #!/usr/bin/python3 at the top of my code. Then why do I see the error AttributeError: module 'systemd.journal' has no attribute 'Priority' only on autostart but not on manual start?