Quantcast
Viewing all articles
Browse latest Browse all 4867

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

When I do not include venv it fails to find the mariadb module. The mariadb module is imported before the sensor_relay module in the script:

Code:

import osimport globimport timeimport sensor_mariadbimport sensor_settingsimport sensor_relay
The ExecStart code is below:

Code:

ExecStart=/usr/bin/python3 /path_to_script/sensor.py
The systemd service status WITHOUT VENV is as follows:
sensor_sample.service - Sampler
Loaded: loaded (/lib/systemd/system/sensor_sample.service; enabled; preset: enabled)
Active: failed (Result: exit-code) since Thu 2024-12-26 09:57:41 EST; 1min 12s ago
Duration: 98ms
Process: 1405 ExecStart=/usr/bin/python3 /home/randy/Documents/GitHub/smrtpype-sensor-sampler/sensor.py (code=exited, status=1/FAILURE)
Main PID: 1405 (code=exited, status=1/FAILURE)
CPU: 91ms

Dec 26 09:57:41 raspberrypi python3[1405]: Traceback (most recent call last):
Dec 26 09:57:41 raspberrypi python3[1405]: File "/home/randy/Documents/GitHub/smrtpype-sensor-sampler/sensor.py", line 9, in <module>
Dec 26 09:57:41 raspberrypi python3[1405]: import sensor_mariadb
Dec 26 09:57:41 raspberrypi python3[1405]: File "/home/randy/Documents/GitHub/smrtpype-sensor-sampler/sensor_mariadb.py", line 13, in <module>
Dec 26 09:57:41 raspberrypi python3[1405]: import local_db_connect
Dec 26 09:57:41 raspberrypi python3[1405]: File "/home/randy/Documents/GitHub/local_db_connect.py", line 4, in <module>
Dec 26 09:57:41 raspberrypi python3[1405]: import mariadb
Dec 26 09:57:41 raspberrypi python3[1405]: ModuleNotFoundError: No module named 'mariadb'
Dec 26 09:57:41 raspberrypi systemd[1]: sensor_sample.service: Main process exited, code=exited, status=1/FAILURE
Dec 26 09:57:41 raspberrypi systemd[1]: sensor_sample.service: Failed with result 'exit-code'.

When I use venv, it finds the mariadb module successfully but fails later in the sendor_relay module. The the sendor_relay module imports are as follows::

Code:

import RPi.GPIO as GPIOimport timeimport sensor_settings
The systemd service status WITH VENV is as follows:
sensor_sample.service - Sampler
Loaded: loaded (/lib/systemd/system/sensor_sample.service; enabled; preset: enabled)
Active: failed (Result: exit-code) since Thu 2024-12-26 10:08:20 EST; 2min 31s ago
Duration: 452ms
Process: 2455 ExecStart=/home/randy/Documents/GitHub/smrtpype-sensor-sampler/.venv/bin/python3 /home/randy/Documents/GitHub/smrtpype-sensor-sampler/senso>
Main PID: 2455 (code=exited, status=1/FAILURE)
CPU: 181ms

Dec 26 10:08:20 raspberrypi systemd[1]: Started sensor_sample.service - Sampler.
Dec 26 10:08:20 raspberrypi python3[2455]: Traceback (most recent call last):
Dec 26 10:08:20 raspberrypi python3[2455]: File "/home/randy/Documents/GitHub/smrtpype-sensor-sampler/sensor.py", line 11, in <module>
Dec 26 10:08:20 raspberrypi python3[2455]: import sensor_heat_tape
Dec 26 10:08:20 raspberrypi python3[2455]: File "/home/randy/Documents/GitHub/smrtpype-sensor-sampler/sensor_heat_tape.py", line 3, in <module>
Dec 26 10:08:20 raspberrypi python3[2455]: import RPi.GPIO as GPIO
Dec 26 10:08:20 raspberrypi python3[2455]: ModuleNotFoundError: No module named 'RPi'
Dec 26 10:08:20 raspberrypi systemd[1]: sensor_sample.service: Main process exited, code=exited, status=1/FAILURE
Dec 26 10:08:20 raspberrypi systemd[1]: sensor_sample.service: Failed with result 'exit-code'.

Statistics: Posted by rlabidin — Thu Dec 26, 2024 6:11 pm



Viewing all articles
Browse latest Browse all 4867

Trending Articles