我有一个连接到 TestStand 并从 .seq (序列)文件中检索某些数据的 python 脚本。
import win32com.client
import pythoncom
TestStandEngine = win32com.client.Dispatch("TestStand.Engine")
Seqfile = TestStandEngine .GetSequenceFileEx("Seq_File.seq")
Main = Seqfile.GetSequenceByName("MainSequence") #Get's the main sequence of the file
我已经安装了 Test Stand 2014 的 x32 和 x64 版本,并且脚本运行得很好。卸载 x64 版本后(因为不需要它),脚本现在给出此错误:
Traceback (most recent call last):
File "C:\ts\Main.py", line 9, in <module>
TestStandEngine = win32com.client.Dispatch("TestStand.Engine")
File "C:\LegacyApp\Python_2.7\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch
dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
File "C:\LegacyApp\Python_2.7\lib\site-packages\win32com\client\dynamic.py", line 114, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\LegacyApp\Python_2.7\lib\site-packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
com_error: (-2147221005, 'Invalid class string', None, None)
在做了一些研究之后,我想我知道是什么导致了这个问题,但我找不到任何方法来解决它。
- 我电脑上的 Python 安装是 32 位的
>>> import platform
>>> platform.architecture()
('32bit', 'WindowsPE')
- 我的电脑上唯一安装的测试台是 32 位版本。
-操作系统:Windows x64 位操作系统
这是我的猜测:我认为当它调度 Teststand.Engine 时,它会尝试使用不再安装的 x64 版本;我尝试添加 clsctx 参数,但结果相同:
win32com.client.Dispatch("TestStand.Engine",clsctx=pythoncom.CLSCTX_LOCAL_SERVER)
有没有办法“强制”它启动 32 位版本?如果 TestStand 是 32 位的,而 Python 是 32 位的,它不应该返回一个 32 位的 COM 对象,该对象应该与 python 32 位一起工作吗?
更新:因此,在 PowerShell 中运行此命令后,它返回了 COM 的所有有效名称的列表,但“ Teststand.Engine ”不在列表中。列表中唯一与 TestStand 相关的对象是 TestStand.ExLauncher (我可以调度它,但它没有与 TestStand.Engine 相同的属性/用途