Python OpenOPC生成的.exe启动报错:Dispatch无效类字符串
问题:PyInstaller打包OPC客户端程序后出现"Invalid class string"错误
之前用32位Python 3.13.2开发了可连接MatrikonOPC仿真服务器并写入标签值的Python程序,通过PyInstaller打包为.exe后运行正常。今日修改程序后重新打包,运行时抛出如下错误:
Traceback (most recent call last): File "win32com\client\dynamic.py", line 81, in _GetGoodDispatch pywintypes.com_error: (-2147221005, 'Invalid class string', None, None) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "OpenOPC\opcda.py", line 95, in win32_init File "win32com\client\gencache.py", line 647, in EnsureDispatch File "win32com\client\__init__.py", line 116, in Dispatch File "win32com\client\dynamic.py", line 101, in _GetGoodDispatchAndUserName File "win32com\client\dynamic.py", line 83, in _GetGoodDispatch pywintypes.com_error: (-2147221005, 'Invalid class string', None, None) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "be_on_net_Simulation.py", line 189, in <module> File "be_on_net_Simulation.py", line 18, in __init__ File "OpenOPC\opcda.py", line 108, in __init__ File "OpenOPC\opcda.py", line 101, in win32_init Exception: ('OPCError', 'Dispatch: Invalid class string')
已尝试的排查操作:
- 更换为32位Python 3.6.8并重装MatrikonOPC仿真服务器,问题未解决
- 将Python 3.13.2移至环境变量Path顶部,无效果
- 旧版本的.exe仍可正常运行
内容的提问来源于stack exchange,提问作者Vukašin Pavković
相关产品推荐
相关产品推荐

