python报错:pywintypes.com_error: (-2147221005,,None,none)


64位win7下编写python脚本,执行时报以下错误:


    EncryptedData = win32com.client.Dispatch('CAPICOM.EncryptedData')
  File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch
    dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
  File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 114, in _GetGoodDispatchAndUserName
    return (_GetGoodDispatch(IDispatch, clsctx), userName)
  File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatch
    IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
pywintypes.com_error: (-2147221005, '\xce\xde\xd0\xa7\xb5\xc4\xc0\xe0\xd7\xd6\xb7\xfb\xb4\xae', None, None)


原因是缺少程序:CAPICOM,但是下载的capicom_dc_sdk.msi是32位的,需要手工注册到64下。
解决过程:


1.安装软件capicom_dc_sdk.msi(下载地址:http://download.csdn.net/detail/tanqingru/8515601)

2.打到capicom.dll,并复制到SysWOW64下:


3.执行以下命令:
C:\Users\qingru.tan>cd C:\Windows\SysWOW64


C:\Windows\SysWOW64>regsvr32.exe capicom.dll


做完后再执行相应程序不再报错

你可能感兴趣的:(Python)