Facing error when python exe service is started after nssm

996 views Asked by At

I have a situation where i have to run a python.exe as a service in NSSM. To test, I have created .exe file which has only import pandas as pd in it. I created the service in NSSM successfully. But when I start the service I get error windows could not start the service on local computer the service did not return an error.

What else can I do to tackle this problem?

Trust me I have tried all solutions in stack overflow.

  1. I closed cmd when starting service.
  2. Gave all control to network service

enter image description here

1

There are 1 answers

0
viilpe On
  1. Install Python in Program Files or another public folder if not already.

  2. If your service are running as the NETWORK SERVICE run CMD with psexec as the NETWORK SERVICE:

     psexec -i -u "nt authority\network service" cmd.exe
    
  3. Install pandas with this cmd.

  4. In cmd check if you can run python and import pandas.

  5. Since services can't have windows you need to somehow check result of your program. For example redirect exception to a file:

     try:
         import pandas
         # do something
     except Exception as e:
         with open(r'c:/service_output.txt', 'wt+') as fd:
             fd.write(repr(e))