How do you run a Python script as a service in Windows?

后端 未结 13 1619
你的背包
你的背包 2020-11-22 02:18

I am sketching the architecture for a set of programs that share various interrelated objects stored in a database. I want one of the programs to act as a service which prov

13条回答
  •  醉话见心
    2020-11-22 02:38

    nssm in python 3+

    (I converted my .py file to .exe with pyinstaller)

    nssm: as said before

    • run nssm install {ServiceName}
    • On NSSM´s console:

      path: path\to\your\program.exe

      Startup directory: path\to\your\ #same as the path but without your program.exe

      Arguments: empty

    If you don't want to convert your project to .exe

    • create a .bat file with python {{your python.py file name}}
    • and set the path to the .bat file

提交回复
热议问题