在Python Web服务器上工作但不在Apache服务器上工作的Win32 COM代码
我正在使用Python并使用Win32 COM库建立ADODB连接,或写入文件或发送outlook消息问题是,当我在内置Python Web服务器上托管代码时,代码运行正常,但当我在Apache Web服务器上托管代码时,代码抛出错误 下面是它抛出错误的代码片段:在Python Web服务器上工作但不在Apache服务器上工作的Win32 COM代码,python,apache,cgi,win32com,Python,Apache,Cgi,Win32com,我正在使用Python并使用Win32 COM库建立ADODB连接,或写入文件或发送outlook消息问题是,当我在内置Python Web服务器上托管代码时,代码运行正常,但当我在Apache Web服务器上托管代码时,代码抛出错误 下面是它抛出错误的代码片段: 169 conn = win32com.client.Dispatch(r'ADODB.Connection') # Making an ADODB connection 170 conn.CommandTimeou
169 conn = win32com.client.Dispatch(r'ADODB.Connection') # Making an ADODB connection
170 conn.CommandTimeout = 7200 # To set the time out time of the connection
171 DSN = "Data Source=DDSP; Database=DDSP; Persist Security Info=True; User ID=" + TDUserName + "; Password=" + TDPassword + "; Session Mode=ANSI;"
conn 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='ADODB.Connection', 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 = 'ADODB.Connection', 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='ADODB.Connection', userName='ADODB.Connection', 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 = 'ADODB.Connection', clsctx = 21, userName = 'ADODB.Connection'
C:\Python27\lib\site-packages\win32com\client\dynamic.py in _GetGoodDispatch(IDispatch='ADODB.Connection', 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 = 'ADODB.Connection', 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'>: (-2147024770, 'The specified module could not be found.', None, None)
argerror = None
args = (-2147024770, 'The specified module could not be found.', None, None)
excepinfo = None
hresult = -2147024770
message = ''
strerror = 'The specified module could not be found.'
对于最后一行,它抛出的错误如下:
<type 'exceptions.AttributeError'>: Excel.Application.Workbooks
args = ('Excel.Application.Workbooks',)
message = 'Excel.Application.Workbooks'
它在最后一行抛出以下错误:
Traceback (most recent call last):
File "E:/CasualUserInterface/CUI - Deployment Package/Test Webapp/webapp/cgi-bin/generate_list.py", line 34, in <module>
olmail()
File "E:/CasualUserInterface/CUI - Deployment Package/Test Webapp/webapp/cgi-bin/generate_list.py", line 32, in olmail
msg.send
File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 511, in __getattr__
ret = self._oleobj_.Invoke(retEntry.dispid,0,invoke_type,1)
com_error: (-2147467260, 'Operation aborted', None, None)
回溯(最近一次呼叫最后一次):
文件“E:/CasualUserInterface/CUI-Deployment Package/Test Webapp/Webapp/cgi bin/generate_list.py”,第34行,在
olmail()
olmail中第32行的文件“E:/CasualUserInterface/CUI-Deployment Package/Test Webapp/Webapp/cgi bin/generate_list.py”
msg.send
文件“C:\Python27\lib\site packages\win32com\client\dynamic.py”,第511行,在\uuu getattr中__
ret=self.\u oleobj\u.Invoke(retEntry.dispid,0,Invoke\u类型,1)
com_错误:(-2147467260,‘操作中止’,无,无)
再次提到,代码在Python Web服务器上运行良好,但在Apache Web服务器上抛出这些错误
任何帮助都将不胜感激。
谢谢有人能回复吗请…回复等待…有人请回复。。。
def ErrorMailer(recipient, cc, queryNum, error):
olapp = win32com.client.Dispatch('Outlook.Application')
msg = olapp.CreateItem(0)
msg.to = recipient
msg.cc = cc
msg.subject = 'Error in the query no. ' + str(queryNum)
mail = 'Query number ' + str(queryNum) + ' resulted in error'
mail += '\nThe error text is ' + str(error)
msg.body = mail
msg.send
Traceback (most recent call last):
File "E:/CasualUserInterface/CUI - Deployment Package/Test Webapp/webapp/cgi-bin/generate_list.py", line 34, in <module>
olmail()
File "E:/CasualUserInterface/CUI - Deployment Package/Test Webapp/webapp/cgi-bin/generate_list.py", line 32, in olmail
msg.send
File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 511, in __getattr__
ret = self._oleobj_.Invoke(retEntry.dispid,0,invoke_type,1)
com_error: (-2147467260, 'Operation aborted', None, None)