Last updated on November 4, 2018
pywinservice, running a simple Python script as a windows service
Code:
Make a virtualenv, store your code there.
Make a run.py file, in that file you can start / call a database, a webcrawler, http, mail or whatever code you want to execute.

When you are done with coding your scripts, test this:
Make a bat file, that will be started when the service starts (i.e 3 party libraries will start)
First:
- Activate the env: ~\pywinservice\Scripts\activate.bat
Second:
- Call the Python script file, ie run.py python app\run.py runserver
Make some log statments also, always good.
If the test is success:
Download NSSM – the Non-Sucking Service Manager.
- nssm install, navigate to your bat file, give the service a name
Start the service with the name you made

Logs for .bat

Log for run.py

Process->Go to service on windows

Service

Note!
This is just a quick and dirty way to run Python scripts as a windows service, but heey, it works and you can automate a lot of scripts!