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:

I 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:

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?

Last edited by Sohil.Mehta on Mon Aug 13, 2018 6:57 pm, edited 1 time in total.

I can see 2 packages called 'systemd'
* package python3-systemd is in the Raspbian repo. This one has the attribute PRIORITY
* module 'systemd' available with pip3 from pypi. This one has Priority

So these 2 are not the same. Did you install both?
Did you install from pypi without 'sudo'? This would mean that if you run the script without sudo then you would use the second version (which is what you did from the CLI)
If you run with sudo (as you did by running from rc.local and most likely when using a service file) then the first version would be used (because the second is only installed for user pi)

I can see 2 ways of solving it (there are probably other ways):
* remove the python3-systemd package if you don't use it. But you have to re-install the other package using 'sudo pip3'
* use a systemd service and run it as user / group pi (add User and Group to Service section)

I did not remove python3-systemd. That wasn't necessary. Also I am yet to test this on /etc/rc.local. But the service file is working absolutely fine. Thanks a lot @DirkS and RaTTus. Sorry for the late reply, I was a bit held up.

I did not remove python3-systemd. That wasn't necessary. Also I am yet to test this on /etc/rc.local. But the service file is working absolutely fine. Thanks a lot @DirkS and RaTTus. Sorry for the late reply, I was a bit held up.

Good!

By leaving both there is still a bit of a risk that the wrong module is found.
But at least you know what's going on and how to solve it.