我一直在使用Python的comtypes模块来自动化Photoshop,但是当我尝试在windows8上执行命令时,我得到了一个TypeError。
这些命令在windows7上运行得很好。
这是我使用的代码示例:
from comtypes.client import CreateObject
psApp = CreateObject("Photoshop.Application")
#Create a new document- this is where it bombs out!
psApp.Documents.Add(1024, 1024, 72, 'new_source_texture', 2, 1, 1)这是我得到的回溯:
Traceback (most recent call last):
File "test.py", line 9, in <module>
psApp.Documents.Add(1024, 1024, 72, 'new_source_texture', 2, 1, 1)
TypeError: '_Dispatch' object is not callable我怀疑这与comtype返回错误类型的对象有关,但我是个新手,所以如果有人能为我指出正确的方向,我将不胜感激!
谢谢!
发布于 2013-02-16 03:44:10
这似乎是一个与Windows8的兼容性问题。一旦我将Python命令行设置为在Windows XP兼容模式下执行,comtypes模块就能正常工作。
同样的修复方法也适用于win32com模块,我尝试过该模块,但遇到了类似的困难。
要在windows 8中设置兼容模式,您可以执行以下步骤:
https://stackoverflow.com/questions/14861258
复制相似问题