最近在把Python的定时程序放进Windows服务时遇到了上述的问题‘错误1053:服务没有及时响应启动或控制请求’ 或者 ‘Error 1053: The service did not respond to the start or control request in a timely fashion’。 可以正常安装python PythonFileName.py install, 不能正常启动python PythonFileName.py start。 尝试使用python PythonFileName.py debug检查代码,没有发现代码问题,考虑应该是环境问题。
最终在StackOverflow的 Can’t start Windows service written in Python (win32serviceutil) 中找到了 BuvinJ 的回答:“It might prove useful in this case to also add these directories to your system path: C:\Python27\Lib\site-packages\win32 and C:\Python27\Lib\site-packages\pywin32_system32. That will let you use pythonservice more easily. ”