解决python写的windows服务不能启动的问题

yipeiwu_com6年前Python基础

报“服务没有及时响应或控制请求”的错误,改用pyinstaller生成也是不行;查资料后修改setup.py如下即可,服务名、脚本名请自行替换:

复制代码 代码如下:

#!/usr/bin/python 
#-*-coding:cp936-*-
from distutils.core import setup
import py2exe

class Target:
    def __init__(self, **kw):
        self.__dict__.update(kw)
        # for the versioninfo resources
        self.version = "1.1.8"
        self.company_name = "Yovole Shanghai Co. Ltd."
        self.copyright = "Copyright (c) 2013 Founder Software (Shanghai) Co., Ltd. "
        self.name = "Guest Agent"


myservice = Target(
    description = 'Yovole Cloud Desktop Guest Agent',
    modules = ['service'],
    cmdline_style='pywin32'
    #icon_resources=[(1, "cartrigde.ico")]
)

options = {"py2exe":  
            {   "compressed": 1,  
                "bundle_files": 1
            }  
          } 

setup(
    service=[myservice],
    options = options,
    zipfile = None,
    windows=[{"script": "service.py"}],
)

 

相关文章

给你一面国旗 教你用python画中国国旗

给你一面国旗 教你用python画中国国旗

本文实例为大家分享了python画中国国旗的具体代码,供大家参考,具体内容如下 # author : momo import turtle #中国国旗 turtle.up() tu...

python实现将html表格转换成CSV文件的方法

本文实例讲述了python实现将html表格转换成CSV文件的方法。分享给大家供大家参考。具体如下: 使用方法:python html2csv.py *.html 这段代码使用了 HTM...

简单了解python数组的基本操作

这篇文章主要介绍了简单了解python数组的基本操作,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 一,创建列表 创建一个列表,只要把...

python pcm音频添加头转成Wav格式文件的方法

如下所示: ''''' add Head Infomation for pcm file ''' import sys import struct import os __...

Python格式化css文件的方法

本文实例讲述了Python格式化css文件的方法。分享给大家供大家参考。具体实现方法如下: import string, sys import re, StringIO TAB=4...