我正在尝试创建Microsoft服务,但出现此错误,全名错误:
导入win32serviceutil文件“ C:\ Users \ User \ AppData \ Local \ Packages \ PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0 \ LocalCache \ local-packages \ Python37 \ site-packages \ win32 \中的“文件“ PythonCornerExample.py”,第1行lib \ win32serviceutil.py“,第9行,在导入win32service,win32api,win32con,winerror中
ImportError:DLL加载失败:找不到指定的模块。”。
我已经尝试安装Visual C ++可再发行的2015,但错误仍然存在。
这是代码:
import win32service
import win32event
import servicemanager
import socket
class AppServerSvc (win32serviceutil.ServiceFramework):
_svc_name_ = "TestService"
_svc_display_name_ = "Test Service"
def __init__(self,args):
win32serviceutil.ServiceFramework.__init__(self,args)
self.hWaitStop = win32event.CreateEvent(None,0,0,None)
socket.setdefaulttimeout(60)
def SvcStop(self):
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
win32event.SetEvent(self.hWaitStop)
def SvcDoRun(self):
servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STARTED,
(self._svc_name_,''))
self.main()
def main(self):
pass
if __name__ == '__main__':
win32serviceutil.HandleCommandLine(AppServerSvc)```
您只需要在64位上重新安装python
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句