Systemd: run scrpit at bootup jetson nano

Hey guys.
i’m trying to set the right parameter to run up a python script when the jetson nano is powered up. I’m facing a problem that the service file doesn’t want to recognize the library that was installed using pip. If the code was compiled from the command line it works fine without facing any problem but with the systemd support i get this error:

The service file looks like the following figure:

i’ll be really gratefull if someone can help me.

I’m not a Python guy, but I imagine it has something similar to a linker for module path search. So I ran this command:
python3.6 --help | less -i

Inside of this it does describe some environment variables which are probably not set up when running via systemd, but part of a user environment in other cases. In that help page I can search for “module” via:
/module
(the “less -i” says the pager will perform case-insensitive searches)

This is the part which sticks out, and you might be able to prefix your command with the environment variables in the script:

PYTHONPATH   : ':'-separated list of directories prefixed to the
               default module search path.  The result is sys.path.
PYTHONHOME   : alternate <prefix> directory (or <prefix>:<exec_prefix>).
               The default module search path uses <prefix>/lib/pythonX.X.

This is your original ExeStart line:
ExecStart=/usr/bin/python3.6 /home/znvidia/Desktop/Drowsiness_detection.py

Don’t know if this will work (I’m mainly a C/C++ coder), but you might try prefixing the command with something like this (but name the path and file based on the module it needs…experimenting likely required):

ExecStart=PYTHONPATH=/some/where/module_name.py /usr/bin/python3.6 /home/znvidia/Desktop/Drowsiness_detection.py

i’m really gratefull for your help. I solved the problem by reinstalling the pip packages as root.
embedded - Runnig a python script using systemd and service file on the jetson nano - Stack Overflow

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.