Generally when running in background it runs as local users and the path that is mentioned would not exists or so…you might need to explicitly install there or use hardcoded python path values
Register the path i.e “C:\Users\LOCAL SERVICE\AppData\Local\Programs\Python\Python39” in the environment variable panel in your system and check it worked for me .
Hope this helps