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

yipeiwu_com5年前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使用pil生成缩略图的方法

本文实例讲述了python使用pil生成缩略图的方法。分享给大家供大家参考。具体分析如下: 这段代码实现python通过pil生成缩略图的功能,会强行将图片大小修改成250x156...

PYQT5设置textEdit自动滚屏的方法

在修改后的文字后面加上: self.textEdit_6.moveCursor(QTextCursor.End) 例子: self.textEdit_6.setPlainTe...

windows系统中python使用rar命令压缩多个文件夹示例

复制代码 代码如下:#!/usr/bin/env python# Filename: backup_ver1.py import osimport time # 1. The files...

Python 处理图片像素点的实例

Python 处理图片像素点的实例

###在做爬虫的时候有时需要识别验证码,但是验证码一般都有干扰物,这时需要对验证码进行预处理,效果如下: from PIL import Image import itertool...

Python为何不能用可变对象作为默认参数的值

Python为何不能用可变对象作为默认参数的值

先来看一道题目: >>> def func(numbers=[], num=1): ... numbers.append(num) ... return numbe...