I have an app that I built with customtkinter. It needs to configure a file and install a python script as a service. That service reads from the config file. It works when I run it from pycharm but when I use auto_py_to_exe the service fails to start with error code 3.
my code runs the following command to install the service and works from pycharm:
cmds = [
'C:/RT_Apps/RT_SIP_Sounder/config/nssm install "RT SIP Alert" "C:/Users/crixe/PycharmProjects/intercomSounder/venv/Scripts/python.exe" "C:/RT_Apps/RT_SIP_Sounder/svc_build/intercom.py"'
]
for cmd in cmds:
subprocess.run(cmd, cwd="C:/RT_Apps/RT_SIP_Sounder/config", stdout=subprocess.PIPE)
print(f"CMD RUN: {cmd} ")
time.sleep(3)
I have tried to point to a local python.exe file included with the exe build, even including the Scripts folder. I know I'm doing something real dumb, but can't seem to figure out what it is.
Don't Know if this will help anybody else.
If you use the NSSM GUI you have three options:
Path points to your executable. If you're running a python script as a service though, the Path should be set to wherever python.exe is.
The full path to your python script you want to run as a service should be split between the Startup directory and the arguments.
So if the script is in C:/myAppFolder/service_dir/service.py,then you would (or could) set the Startup directory to c:/myAppFolder/ (watch the slash) with the arguments being service_dir/service.py
If you were installing from a script you would run the install followed by the set commands:
This is what has worked for me in getting NSSM to install a py script as windows service without pausing.