Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4863

Beginners • Cannot find RPi in systemd but finds it in ssh

$
0
0
I have a script that I want to run, starting with bootup on a Raspberry Pi.
Although I am not totally sure, but I believe this script was running successfully in systemd before a recent RasberryPI update.

Below is the code In/lib/systemd/system/sensor_sample.service:

Code:

[[Unit]Description=SamplerAfter=multi-user.target[Service]Type=SimpleUser=randyWorkingDirectory=/home/randy/Documents/GitHub/smrtpype-sensor-samplerExecStart=/home/randy/Documents/GitHub/smrtpype-sensor-sampler/.venv/bin/python3 /home/randy/Documents/GitHub/smrtpype-sensor-sampler/sensor.pyReStart=on.abort[Install]WantedBy=multi-user.target
I import RPi using:

Code:

import RPi.GPIO as GPIO
and the script runs successfully in an environment at /home/randy/Documents/GitHub/smrtpype-sensor-sampler/sensor.py in ssh.

However, it fails at bootup. Below is the status from $ sudo systemctl status sensor_sample:
x sensor_sample.service - Sampler
Loaded: loaded (/lib/systemd/system/sensor_sample.service; enabled; preset: enabled)
Active: failed (Result: exit-code) since Mon 2024-12-23 18:49:42 EST; 1min 8s ago
Duration: 565ms
Process: 1602 ExecStart=/home/randy/Documents/GitHub/smrtpype-sensor-sampler/.venv/bin/python3 /home/randy/Documents/GitHub/smrtpype-sensor-sampler/sensor.py (code=exited, status=1/FAILURE)
Main PID: 1602 (code=exited, status=1/FAILURE)
CPU: 223ms

Dec 23 18:49:42 raspberrypi systemd[1]: Started sensor_sample.service - Sampler.
Dec 23 18:49:42 raspberrypi python3[1602]: Traceback (most recent call last):
Dec 23 18:49:42 raspberrypi python3[1602]: File "/home/randy/Documents/GitHub/smrtpype-sensor-sampler/sensor.py", line 11, in <module>
Dec 23 18:49:42 raspberrypi python3[1602]: import sensor_heat_tape
Dec 23 18:49:42 raspberrypi python3[1602]: File "/home/randy/Documents/GitHub/smrtpype-sensor-sampler/sensor_heat_tape.py", line 3, in <module>
Dec 23 18:49:42 raspberrypi python3[1602]: import RPi.GPIO as GPIO
Dec 23 18:49:42 raspberrypi python3[1602]: ModuleNotFoundError: No module named 'RPi'
Dec 23 18:49:42 raspberrypi systemd[1]: sensor_sample.service: Main process exited, code=exited, status=1/FAILURE
Dec 23 18:49:42 raspberrypi systemd[1]: sensor_sample.service: Failed with result 'exit-code'.
I would greatly appreciate any help.

Statistics: Posted by rlabidin — Tue Dec 24, 2024 12:10 am



Viewing all articles
Browse latest Browse all 4863

Trending Articles