Python 3 executable as windows service

后端 未结 3 1259
孤街浪徒
孤街浪徒 2021-02-05 19:33

I\'m trying to write a windows Service in python, but the tricky part is i want to deploy it on a machine that doesn\'t have python. I\'ve successfully created a service like th

3条回答
  •  旧时难觅i
    2021-02-05 20:35

    I've edited the Win32Service.c in the cx_freeze src for python3 support

    Edited it with some preprocessor commands, for python2 support too (but not tested for python2 yet)

    1. download sources of cx_freeze from pypi and extract it
    2. download cx_logging and extract it to the cx_freeze-4.3.4 directory
    3. replace the Win32Service.c file in cx_Freeze-4.3.4\source\bases with my edited version
    4. edit line 170 in setup.py from if moduleInfo is not None and sys.version_info[:2] < (3, 0): to if moduleInfo is not None:
    5. run python setup.py build in cx_freeze-4.3.4 directory (you must have MSC installed to compile the C source files)
    6. copy cx_Freeze-4.3.4\build\lib.win32-3.4\cx_Freeze\bases\Win32Service.exe to C:\Python34\Lib\site-packages\cx_Freeze\bases (or the path where your python3 is installed)
    7. now you can create frozen exe with the Win32Service base (no more the cx_Freeze.freezer.ConfigError: no base named Win32Service error)

提交回复
热议问题