Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python 3.6 ~ AttributeError: module 'servicemanager' has no attribute 'Initialize' ~ When creating windows service exe

When using any version of servicemanager with Python 3.6.6 I get AttributeError: module 'servicemanager' has no attribute 'Initialize'*

Code Snippet:

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

This seems to be the standard main function of any windows service written in python.

Any help would be greatly appreciated!

like image 872
Bradley Lauder Avatar asked Mar 05 '26 00:03

Bradley Lauder


1 Answers

I think install servicemanager for error:

\Python38-32\Scripts\pip3 uninstall servicemanager

After it works.

like image 195
Massimo Avatar answered Mar 06 '26 14:03

Massimo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!