>>> sht.pictures.add()
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\win32com\client\gencache.py", line 236, in GetModuleForCLSID
__import__(sub_mod_name)
ModuleNotFoundError: No module named 'win32com.gen_py.45541000-5750-5300-4B49-4E47534F4655x0x3x0.Pictures'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):File “
sht.pictures.add()
File “C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\xlwings\main.py”, line 967, in pictures
return Pictures(impl=self.impl.pictures)
File “C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\xlwings_xlwindows.py”, line 661, in pictures
return Pictures(xl=self.xl.Pictures())
File “C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\win32com\gen_py\45541000-5750-5300-4B49-4E47534F4655x0x3x0_Worksheet.py”, line 195, in Pictures
ret = Dispatch(ret, ‘Pictures’, None)
File “C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\win32com\client_init_.py”, line 96, in Dispatch
return _WrapDispatch(dispatch, userName, resultCLSID, typeinfo, clsctx=clsctx)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\win32com\client_init.py", line 37, in __WrapDispatch
klass = gencache.GetClassForCLSID(resultCLSID)
File “C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\win32com\client\gencache.py”, line 183, in GetClassForCLSID
mod = GetModuleForCLSID(clsid)
File “C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\win32com\client\gencache.py”, line 244, in GetModuleForCLSID
makepy.GenerateChildFromTypeLibSpec(sub_mod, info)
File “C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\win32com\client\makepy.py”, line 296, in GenerateChildFromTypeLibSpec
tlb = pythoncom.LoadRegTypeLib(typelibCLSID, major, minor, lcid)
pywintypes.com_error: (-2147319779, ‘库没有注册。’, None, None)
解决方法:
用下面的语句找到报错的文件夹所在路径。
>>> from win32com.client.gencache import EnsureDispatch
>>> import sys
>>> xl=EnsureDispatch('Excel.Application')
>>> sys.modules[xl.__module__].__file__
'C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\win32com\gen_py\00020813-0000-0000-C000-000000000046x0x1x9\_Application.py'
修改上面目录外的其他临时目录的目录名,如下图所示。
现在可以正常使用了。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)