首页 > 解决方案 > Python 3.6 ~ AttributeError: module 'servicemanager' has no attribute 'Initialize' ~ 创建windows service exe时

问题描述

当使用 with 的任何版本时servicemanagerPython 3.6.6我得到AttributeError: module 'servicemanager' has no attribute 'Initialize'*

代码片段:

if __name__ == '__main__':
    if len(sys.argv) == 1:
        servicemanager.Initialize()
        servicemanager.PrepareToHostSingle(RelayService3)
        servicemanager.StartServiceCtrlDispatcher()
    else:
        win32serviceutil.HandleCommandLine(RelayService3)

这似乎是任何windowspython.

任何帮助将不胜感激!

标签: pythonwindowsservicepython-3.6servicemanager

解决方案


我认为安装 servicemanager 错误:

\Python38-32\Scripts\pip3 uninstall servicemanager

在它工作之后。


推荐阅读