I want to automate some tasks in Photoshop using python win32com. But I'm getting error while dispatching the Photoshop Application, error along with code show below. I have tried solutions available on stackoverflow like deleting genpy folder, reinstall packages, reinstall photoshop but none of them works. Similar discussion links Link1 Link2
import win32com.client as win32
app = win32.gencache.EnsureDispatch("Photoshop.Application")
com_error Traceback (most recent call last)
File ~\miniconda3\lib\site-packages\win32com\client\gencache.py:621, in EnsureDispatch(prog_id, bForDemand)
620 try:
--> 621 ti = disp._oleobj_.GetTypeInfo()
622 disp_clsid = ti.GetTypeAttr()[0]
com_error: (-2147312566, 'Error loading type library/DLL.', None, None)
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
Cell In[3], line 1
----> 1 app = win32.gencache.EnsureDispatch("Photoshop.Application.130")
2 app
File ~\miniconda3\lib\site-packages\win32com\client\gencache.py:633, in EnsureDispatch(prog_id, bForDemand)
631 disp = disp_class(disp._oleobj_)
632 except pythoncom.com_error:
--> 633 raise TypeError(
634 "This COM object can not automate the makepy process - please run makepy manually for this object"
635 )
636 return disp
TypeError: This COM object can not automate the makepy process - please run makepy manually for this object
If I use win32.Disptach
instead of win32.gencache.EnsureDispatch
, then I'm not getting error but results has no use as not able to execute any command.
I tried loading in with PowerShell "New-Object -ComObject" command. But it also doesn't give desired results. Below screenshot shows outcome is not proper. Also, it throws error if i try any com method.
For reference below are powershell results of another machine where it runs without any issue on PowerShell as well as on python.