【问题标题】:wincom32.client.Dispatch not working after upgrade to Python 3.8升级到 Python 3.8 后 win32com.client.Dispatch 无法正常工作
【发布时间】:2020-08-20 09:36:22
【问题描述】:

我刚刚升级到 Python 3.8.2。升级后我重新安装了一些我经常使用的软件包

python -m pip install --upgrade pip
pip install -U wxPython
pip install pywin32
pip install python-vlc
pip install PyAutoIt

现在我发现我不能再创建 COM 对象了。一个最小的例子是

import win32com.client
aut = win32com.client.Dispatch("AutoItX3.Control")

这会导致

Traceback (most recent call last):
  File "C:\Python\lib\site-packages\win32com\client\dynamic.py", line 89, in _GetGoodDispatch
    IDispatch = pythoncom.connect(IDispatch)
pywintypes.com_error: (-2147221021, 'Operation unavailable', None, None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\testwin32.py", line 2, in <module>
    aut = win32com.client.Dispatch("AutoItX3.Control")
  File "C:\Python\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch
    dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
  File "C:\Python\lib\site-packages\win32com\client\dynamic.py", line 114, in _GetGoodDispatchAndUserName
    return (_GetGoodDispatch(IDispatch, clsctx), userName)
  File "C:\Python\lib\site-packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatch
    IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
pywintypes.com_error: (-2147221164, 'Class not registered', None, None)

这是 Python 3.8.2、win32com 的问题,还是我需要重新初始化?

【问题讨论】:

    标签: python com win32com dispatch


    【解决方案1】:

    发现问题。当我安装 Python 3.8.2 时,我选择了 32 位版本。我使用 64 位版本重新安装,问题就消失了。

    【讨论】:

      猜你喜欢
      • 2016-12-04
      • 1970-01-01
      • 1970-01-01
      • 2015-11-03
      • 2020-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多