I have a python script which uses motion sensor and camera. It captures an image and stores to the same folder where the script resides. No errors when I run it in bash. But I created this service for systemd to make it run on start up:
[Unit]
Description=Run office intrusion detection
After=network.Target
[Service]
ExecStart=/usr/bin/python3 -u /home/myuser/Documents/prog/pricam.py
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=pricam
User=pi
[Install]
WantedBy=multi-user.target
and when it runs I see this error:
>>Traceback (most recent call last):
File "/home/alvipeo/Documents/progs/pricam.py", line 24, in <module>
camera.capture(filename)
File "/usr/lib/python3/dist-packages/picamera/camera.py", line 1418, in capture
encoder.start(output)
File "/usr/lib/python3/dist-packages/picamera/encoders.py", line 1126, in start
super(PiCookedOneImageEncoder, self).start(output)
File "/usr/lib/python3/dist-packages/picamera/encoders.py", line 375, in start
self._open_output(output)
File "/usr/lib/python3/dist-packages/picamera/encoders.py", line 331, in _open_outpu
t self.outputs[key] = mo.open_stream(output)
File "/usr/lib/python3/dist-packages/picamera/mmalobj.py", line 344, in open_stream
stream = io.open(stream, 'wb' if output else 'rb', buffering)
PermissionError: [Errno 13] Permission denied: '/home/myuser/Documents/progs/pi
cam-2018-06-06_11.46.38.jpg'
I'm not a good linux user, so could you please tell me what's wrong here?