1053錯誤
代碼運行沒有問題后,安裝服務,然而start 的時候出現錯誤 1053:服務沒有及時響應啟動或控制請求(Error 1053: The service did not respond to the start or control request in a timely fashion)
試了幾個網上找到的代碼,都是這個現象,所以應該不是代碼的問題。
后面找到解決方法:
What you need to do is to add the Python27 to SYSTEM PATH, and not to USER PATH, since as a default the python service will get installed as a 'LocalSystem' and so when it attempts to start it uses the SYSTEM PATH variable - that's why you can run it from the command prompt, your USER PATH is right.
python默認安裝是作為LocalSystem,配置的是用戶路徑而不是環境變量,所以需要添加環境變量。
在用戶變量處去掉python路徑,然后在環境變量加入python路徑
C:\Users\zhongjianhui\AppData\Local\Programs\Python\Python36\Lib\site-packages\pywin32_system32;
C:\Users\zhongjianhui\AppData\Local\Programs\Python\Python36\Lib\site-packages\win32;
C:\Users\zhongjianhui\AppData\Local\Programs\Python\Python36\Scripts\;C:\Users\zhongjianhui\AppData\Local\Programs\Python\Python36\
start service成功。