我想,只要有一个使用win32com Objects是encoutered代码部署在IIS web服务器Python应用程序,它会抛出错误,但代码工作在Python中内置的Web服务器下面罚款的代码:
xlapp = win32com.client.Dispatch(R “Excel.Application”)
这里是错误:
xlapp undefined, global win32com = <module 'win32com' from 'C:\Python27\lib\site-packages\win32com\__init__.pyc'>, win32com.client = <module 'win32com.client' from 'C:\Python27\lib\site-packages\win32com\client\__init__.pyc'>, win32com.client.Dispatch = <function Dispatch>
C:\Python27\lib\site-packages\win32com\client\__init__.py in Dispatch(dispatch='Excel.Application', userName=None, resultCLSID=None, typeinfo=None, UnicodeToString=None, clsctx=21)
93 """
94 assert UnicodeToString is None, "this is deprecated and will go away"
=> 95 dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
96 return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo, clsctx=clsctx)
97
dispatch = 'Excel.Application', userName = None, global dynamic = <module 'win32com.client.dynamic' from 'C:\Python27\lib\site-packages\win32com\client\dynamic.pyc'>, dynamic._GetGoodDispatchAndUserName = <function _GetGoodDispatchAndUserName>, clsctx = 21
C:\Python27\lib\site-packages\win32com\client\dynamic.py in _GetGoodDispatchAndUserName(IDispatch='Excel.Application', userName='Excel.Application', clsctx=21)
113 else:
114 userName = str(userName)
=> 115 return (_GetGoodDispatch(IDispatch, clsctx), userName)
116
117 def _GetDescInvokeType(entry, default_invoke_type):
global _GetGoodDispatch = <function _GetGoodDispatch>, IDispatch = 'Excel.Application', clsctx = 21, userName = 'Excel.Application'
C:\Python27\lib\site-packages\win32com\client\dynamic.py in _GetGoodDispatch(IDispatch='Excel.Application', clsctx=21)
90 IDispatch = pythoncom.connect(IDispatch)
91 except pythoncom.ole_error:
=> 92 IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
93 else:
94 # may already be a wrapped class.
IDispatch = 'Excel.Application', global pythoncom = <module 'pythoncom' from 'C:\windows\system32\pythoncom27.dll'>, pythoncom.CoCreateInstance = <built-in function CoCreateInstance>, builtin None = None, clsctx = 21, pythoncom.IID_IDispatch = IID('{00020400-0000-0000-C000-000000000046}')
<class 'pywintypes.com_error'>:(-2147024891, 'Access is denied.', None, None)
argerror = None
args = (-2147024891, 'Access is denied.', None, None)
excepinfo = None
hresult = -2147024891
message = ''
strerror = 'Access is denied.'