I am trying to use a Python API which makes use of the win32com library. I am using a sample code provided by the site, which works fine in one computer but fails in another. I am running it on Windows 7. Specifically it fails while checking for some binaries:
import win32event
import win32com.client
from win32com.client import constants
win32com.client.gencache.EnsureModule('{51F35562-AEB4-4AB3-99E8-AC9666344B64}', 0, 4, 0)
win32com.client.gencache.EnsureModule('{4D454F08-B770-11D4-A18E-00C04F6BB385}', 0, 17, 12801)
I have been looking around the internet but although there are similar questions I haven't found the answer to my problem. At first I though it was because some 32-64 bits difference in the Windows or Python distributions. I checked that the Windows version was the same in both computers (64-bit Windows 7) and that I was using the same Python version. I haven't found neither which module corresponds to the codes inside EnsureModule().
I am a newby in these aspects and I don't know well the COM objects, so sorry my description is not accurate enough.
Thanks in advance.
Edit:
The import of win32com works well. It doesn't return an error for example using the code of the question referenced as possible duplicate:
from win32com.client import Dispatch
xlApp = win32com.client.Dispatch("Excel.Application")
this doesn't return any error.
The exact code and error displayed is :
win32com.client.gencache.EnsureModule('{51F35562-AEB4-4AB3-99E8-AC9666344B64}', 0, 4, 0)
Traceback (most recent call last):
File "<ipython-input-2-18c1ec54bb40>", line 1, in <module>
win32com.client.gencache.EnsureModule('{51F35562-AEB4-4AB3-99E8-AC9666344B64}', 0, 4, 0)
File "C:\Users\jredondo\AppData\Local\Continuum\anaconda3\lib\site-packages\win32com\client\gencache.py", line 518, in EnsureModule
module = MakeModuleForTypelib(typelibCLSID, lcid, major, minor, progressInstance, bForDemand = bForDemand, bBuildHidden = bBuildHidden)
File "C:\Users\jredondo\AppData\Local\Continuum\anaconda3\lib\site-packages\win32com\client\gencache.py", line 287, in MakeModuleForTypelib
makepy.GenerateFromTypeLibSpec( (typelibCLSID, lcid, major, minor), progressInstance=progressInstance, bForDemand = bForDemand, bBuildHidden = bBuildHidden)
File "C:\Users\jredondo\AppData\Local\Continuum\anaconda3\lib\site-packages\win32com\client\makepy.py", line 223, in GenerateFromTypeLibSpec
tlb = pythoncom.LoadRegTypeLib(typelibCLSID, major, minor, lcid)
com_error: (-2147319779, 'Library not registered.', None, None)
I have tried in seven different computers with Windows 7 (it should be the same distribution since the one the company is subscribed) with different Python versions (Python 2.7 and 3.6 on 32 and 64 bits) and in four of them it works well while in the other three it returns the com_error described above.
I have installed the same version (32-bit Python 3.5.2) as in two different computers and in the first one both lines work well while in the second computer just the first one works and the second throws an error. For lines I mean:
win32com.client.gencache.EnsureModule('{51F35562-AEB4-4AB3-99E8-AC9666344B64}', 0, 4, 0)
win32com.client.gencache.EnsureModule('{4D454F08-B770-11D4-A18E-00C04F6BB385}', 0, 17, 12801)
Maybe there is a problem related to Windows updates. I haven't found neither to what it corresponds exactly the modules of the serial code inside the EnsureModule().