Python Flask as Windows Service

后端 未结 2 1146
我寻月下人不归
我寻月下人不归 2021-02-01 07:15

I am trying to get a Flask app to run as a Service in Windows. I have already tried to implement a solution as suggested here and here without success.

I ha

2条回答
  •  臣服心动
    2021-02-01 08:15

    I looked further into pyinstaller github repo and solved this issue.

    It seems that pyinstaller has some conflicts with Windows 10, but this issue was the key to my problem. Althoug the module producing the error was not the same.

    I managed to solve it by adding a SystemError exception at lib\site-packages\click\utils.py, line 260 in the echo function.

    So I change this:

    if message:
       file.write(message)
    

    To this:

    if message:
        try:
            file.write(message)
        except SystemError:
            pass
    

    Rebuilt the exe using:

    pyinstaller --onefile --hidden-import win32timezone win32_service.py
    

    Installed the service, and then it started correctly.

提交回复
热议问题