Hi everyone, I’m trying to run a py script when starting up my jetson but I’m getting the following error:
Dec 22 12:50:45 nvidia-desktop systemd[1]: Started My Script.
Dec 22 12:50:45 nvidia-desktop python3[3910]: Traceback (most recent call last):
Dec 22 12:50:45 nvidia-desktop python3[3910]: File “/home/pino/Desktop/ProgrammaTelai/main.py”, line 13, in
Dec 22 12:50:45 nvidia-desktop python3[3910]: from ultralytics import YOLO
Dec 22 12:50:45 nvidia-desktop python3[3910]: ModuleNotFoundError: No module named ‘ultralytics’
Dec 22 12:50:45 nvidia-desktop systemd[1]: myscript.service: Main process exited, code=exited, status=1/FAILURE
Dec 22 12:50:45 nvidia-desktop systemd[1]: myscript.service: Failed with result ‘exit-code’.
To run it I created this file:
sudo nano /etc/systemd/system/myscript.service
[Unit]
Description=My Script
After=multi-user.target
[Service]
Environment=XAUTHORITY=/home/pino/.Xauthority
Environment=DISPLAY=:0
Environment=“PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/pino/.local/bin”
ExecStart=/usr/bin/python3 /home/pino/Desktop/ProgrammaTelai/main.py
[Install]
WantedBy=multi-user.target
(with the first 2 Environments added because I found them as a solution on another forum, but to be honest I don’t know what they do or if they are present in my system and the situation doesn’t change, it doesn’t work!)
and then I ran these commands:
sudo systemctl enable myscript
sudo systemctl start myscript
sudo journalctl -u myscript (for see the error)
for information, my libraries that I recall in the file have the following paths:
$ which python3
/usr/bin/python3
$ which ultralytics
/home/pino/.local/bin/ultralytics
path of the script to execute: /home/pino/Desktop/ProgrammaTelai/main.py
(main.py also calls other py files inside it which are always inside the same ProgrammaTelai folder)
I need your precious help once again!
How can I do?
Am I doing everything wrong and is there another way to run a script at system startup or do I simply need to change something?
I await your help, Thanks in advance to anyone who replies!