After deleting C:\Temp\gen_py, the code above works again. Hope it can save trouble!

PS. Or, you can try searching gen_py in your %TEMP% folder;

Answer from theVerse on Stack Overflow
🌐
Pythonmana
pythonmana.com › 2021 › 09 › 20210904095022745c.html
Python 3 operation excel reports an error attributeerror: module 'win32com.gen_ py has no attribute ‘CLSIDToClassMap‘
September 4, 2021 - Traceback (most recent call last): File "F:\Python\lib\site-packages\xlwings\_xlwindows.py", line 288, in __init__ File "F:\Python\lib\site-packages\win32com\client\__init__.py", line 114, in DispatchEx File "F:\Python\lib\site-packages\win32com\client\__init__.py", line 96, in Dispatch File "F:\Python\lib\site-packages\win32com\client\__init__.py", line 37, in __WrapDispatch File "F:\Python\lib\site-packages\win32com\client\gencache.py", line 183, in GetClassForCLSID File "F:\Python\lib\site-packages\win32com\client\gencache.py", line 226, in GetModuleForCLSID File "F:\Python\lib\site-packages\win32com\client\gencache.py", line 266, in GetModuleForTypelib File "F:\Python\lib\site-packages\win32com\client\gencache.py", line 558, in AddModuleToCache AttributeError: module 'win32com.gen_py.00020813-0000-0000-C000-000000000046x0x1x9' has no attribute 'CLSIDToClassMap' Abnormal operation
Discussions

python 3.x - Why am I suddenly getting a no attribute 'CLSIDToPackageMap' error with win32com.client? - Stack Overflow
Communities for your favorite technologies. Explore all Collectives · Ask questions, find answers and collaborate at work with Stack Overflow Internal More on stackoverflow.com
🌐 stackoverflow.com
python-win32com excel com model started generating errors - Stack Overflow
It works for me! I had got module 'win32com.gen_py.00020813-0000-0000-C000-000000000046x0x1x9' has no attribute 'CLSIDToClassMap' error. After deleting the gen_py folder, problem solved. More on stackoverflow.com
🌐 stackoverflow.com
AttributeError: module 'win32com.gen_py.00020813-0000-0000-C000-000000000046x0x1x9' has no attribute 'CLSIDToClassMap'
8.8.8.8 的 Ping 統計資料: 封包: 已傳送 = 4,已收到 = 4, 已遺失 = 0 (0% 遺失), 大約的來回時間 (毫秒): 最小值 = 19ms,最大值 = 20ms,平均 = 19ms 網路連線確認OK ... Traceback (most recent call last): File ".\output_excel.py", line 385, in More on github.com
🌐 github.com
0
December 27, 2018
Weird errorr trying to read outlook calendar
Whats the entire error message, please post it fully. More on reddit.com
🌐 r/learnpython
6
1
June 18, 2020
🌐
Python
mail.python.org › pipermail › python-win32 › 2007-August › 006147.html
[python-win32] python com error - 'module' object has no attribute 'CLSIDToClassMap' strangeness
August 1, 2007 - Importing module Failed to execute ... info.lcid, info.major, info.minor) File "C:\Python25\Lib\site-packages\win32com\client\gencache.py", line 554, in AddModuleToCache dict = mod.CLSIDToClassMap AttributeError: 'module' object has no attribute 'CLSIDToClassMap' Deleting the ...
🌐
GitHub
gist.github.com › rdapaz › 63590adb94a46039ca4a10994dff9dbe
Fix for module win32com.gen_py has no attribute 'CLSIDToPackageMap' · GitHub
[…] try: xl = client.gencache.EnsureDispatch('Excel.Application') except AttributeError: […] # Remove cache and try again. MODULE_LIST = [m.__name__ for m in sys.modules.values()] for module in MODULE_LIST: if re.match(r'win32com\.gen_py\..+', module): del sys.modules[module] shutil.rmtree(os.path.join(os.environ.get('LOCALAPPDATA'), 'Temp', 'gen_py')) […]
🌐
GitHub
github.com › dictation-toolbox › dragonfly › issues › 359
Launching sapi5 win32com has no attribute CLSIDToClassMap · Issue #359 · dictation-toolbox/dragonfly
When launching sapi5 via cli I get; WARNING:engine:Exception while initializing sapi5 engine: module 'win32com.gen_py.C866CA3A-32F7-11D2-9602-00C04F8EE628x0x5x4' has no attribute 'CLSIDToClassMap' ERROR:command:Exception while initializi...
Author   dictation-toolbox
Top answer
1 of 7
66

I had the same issue and I resolved it by following the instructions here: https://mail.python.org/pipermail/python-win32/2007-August/006147.html

Deleting the gen_py output directory and re-running makepy SUCCEEDS and subsequently the test application runs OK again.

So the symptom is resolved, but any clues as to how this could have happened. This is a VERY long running application (think 24x7 for years) and I'm concerned that whatever caused this might occur again.

To find the output directory, run this in your python console / python session:

import win32com
print(win32com.__gen_path__)

or, even better, a one-liner in the command line:

python -c "import win32com; print(win32com.__gen_path__)"

Based on the exception message in your post, the directory you need to remove will be titled '00020813-0000-0000-C000-000000000046x0x1x9'. So delete this directory and re-run the code. And if you're nervous about deleting it (like I was) just cut the directory and paste it somewhere else.

💡Note that this directory is usually in your "TEMP" directory (copy-paste %TEMP%/gen_py in Windows File Explorer and you will arrive there directly).

I have no idea why this happens nor do I know how to prevent it from happening again, but the directions in the link I provided seemed to work for me.

2 of 7
22

A more straightforward solution was posted in a related question Issue in using win32com to access Excel file.

Basically, you just need to delete the folder C:\Users\<your username>\AppData\Local\Temp\gen_py and rerun your code.

💡TIP: You can also put in your Windows file explorer %TEMP%\gen_py to access it directly, and then delete its content.

Find elsewhere
🌐
Freelancer
freelancer.ie › projects › python › fix-gen-cache-win-issues
Fix Gen Cache and Win32 issues | Freelancer
Here's the error code: See the ... SetTypelibForAllClsids([login to view URL]) AttributeError: module 'win32com.gen_py.00020813-0000-0000-C000-000000000046x0x1x9' has no attribute 'CLSIDToClassMap' During handling of the above exception, another exception occurred: Traceback ...
🌐
Mlln
mlln.cn › 2018 › 04 › 23 › win32com-gen-py错误has-no-attribute-CLSIDToClassMap
win32com.gen_py错误has no attribute CLSIDToClassMap | DataSense
office自动化的开发很麻烦, 很多东西不是很懂, 发生错误也不知道怎么回事. 今天遇到一个错误, 运行下面这个语句的时候发生的: · 错误的详细信息如下:
🌐
Medium
medium.com › @RunRyan › python-has-no-attribute-clsidtoclassmap-error-대응책-2eafefafc6a
[python] has no attribute ‘CLSIDToClassMap’ Error 대응책 | by RunRyan | Medium
December 15, 2019 - 읽어 보니 win32com 의 dispatch하는 작업에서 애러가 나는 것( 나는 뭉터기로 계속 쓰던 파일이라 일단 검색 부터 하여 어느 코드에서 애러나는지 찾지 않았다.ㅋㅋㅋ)이라 하였고 “ \AppData\Local\Temp\gen_py\3.7”에 있는 error 에 나와있는 폴더를 삭제 하고 파일을 재 실행 하면 문제 없이 진행이 된다는 내용이었다. (역시 중국사이트는 내 취향임, 이유가 없고 해결법만 있음 ㅋㅋ) . 주석에 달린 (https://mlln.cn/2018/04/23/win32com-gen-py错误has-no-attribute-CLSIDToClassMap/) 에 들어가면 조금 더 나은 설명이 나오는데
🌐
Reddit
reddit.com › r/learnpython › weird errorr trying to read outlook calendar
r/learnpython on Reddit: Weird errorr trying to read outlook calendar
June 18, 2020 -

I have written a program to read my outlook calendar (and write it to my google calendar), mostly just to practice some python/learn from it/for fun. Now this was all fun and games and it worked, although it needed some improvements.

However it stopped beging fun and games when it decided to break itself. Literally. I didn't chage a letter of code and suddenly it returns an errormessage.

The faulty bit of code seems to be:

import win32com.client

def read_outlook_calendar(some arguments):
    Outlook = win32com.client.Dispatch("Outlook.Application")
    more of this function

where this worked before, it now returns the following error:

  File "syncal2.py", line 17, in <module>
    appointments = fun.read_outlook_calendar(begin = begin, end = end)
  File "C:\Users\Gebruiker\Documents\Agendaproject\tidy\fun.py", line 8, in read_outlook_calendar
    Outlook =  win32com.client.gencache.EnsureDispatch("Outlook.Application")
  File "C:\Users\Gebruiker\anaconda3\lib\site-packages\win32com\client\gencache.py", line 527, in EnsureDispatch
    disp = win32com.client.Dispatch(prog_id)
  File "C:\Users\Gebruiker\anaconda3\lib\site-packages\win32com\client\__init__.py", line 96, in Dispatch
    return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo, clsctx=clsctx)
  File "C:\Users\Gebruiker\anaconda3\lib\site-packages\win32com\client\__init__.py", line 37, in __WrapDispatch
    klass = gencache.GetClassForCLSID(resultCLSID)
  File "C:\Users\Gebruiker\anaconda3\lib\site-packages\win32com\client\gencache.py", line 183, in GetClassForCLSID
    mod = GetModuleForCLSID(clsid)
  File "C:\Users\Gebruiker\anaconda3\lib\site-packages\win32com\client\gencache.py", line 226, in GetModuleForCLSID
    mod = GetModuleForTypelib(typelibCLSID, lcid, major, minor)
  File "C:\Users\Gebruiker\anaconda3\lib\site-packages\win32com\client\gencache.py", line 266, in GetModuleForTypelib
    AddModuleToCache(typelibCLSID, lcid, major, minor)
  File "C:\Users\Gebruiker\anaconda3\lib\site-packages\win32com\client\gencache.py", line 552, in AddModuleToCache
    dict = mod.CLSIDToClassMap
AttributeError: module 'win32com.gen_py.00062FFF-0000-0000-C000-000000000046x0x9x6' has no attribute 'CLSIDToClassMap'

So yeah, how do I unfuck this?

🌐
Alteryx Community
community.alteryx.com › t5 › Alteryx-Designer-Desktop-Discussions › Python-Error-CLSIDtopackagemap › td-p › 662319
Python Error - CLSIDtopackagemap - Alteryx Community
November 6, 2020 - Hi Alteryx, I'm suddenly running into CLSIDtopackagemap when trying to run pywin32 related package (like xlwings or win32com.client). The issue appeared on both Alteryx and Anaconda3 IDE (spyder) I'm using. Previously pywin32 was functioning just fine. import xlwings ExcelApp = xlwings.App Attri...
🌐
GitHub
github.com › chaosparrot › parrot.py › blob › master › README.md
parrot.py/README.md at master · chaosparrot/parrot.py
Sometimes if windows speech rec ... You can fix that by starting windows speech rec, going to your C:\Users\YOURUSER\AppData\Local\Temp directory and rename gen_py to gen_py2 or something....
Author   chaosparrot
🌐
GitHub
github.com › michaelgundlach › pyspeech › issues › 18
unable to import speech module · Issue #18 · michaelgundlach/pyspeech
March 19, 2015 - At the end I just copied the code from the home page and I got the following error message: Traceback (most recent call last): File "C:/Documents and Settings/jori/Desktop/test_speech.py", line 1, in <module> import speech File "C:\Python25\lib\site-packages\speech-0.5.2-py2.5.egg\speech.py", line 63, in <module> File "C:\Python25\lib\site-packages\win32com\client\gencache.py", line 393, in EnsureModule module = GetModuleForTypelib(typelibCLSID, lcid, major, minor) File "C:\Python25\lib\site-packages\win32com\client\gencache.py", line 262, in GetModuleForTypelib AddModuleToCache(typelibCLSID, lcid, major, minor) File "C:\Python25\lib\site-packages\win32com\client\gencache.py", line 554, in AddModuleToCache dict = mod.CLSIDToClassMap AttributeError: 'module' object has no attribute 'CLSIDToClassMap' I tried just to import speech without any other code and I got the same error.
Author   michaelgundlach
🌐
The Mail Archive
mail-archive.com › spyderlib@googlegroups.com › msg07052.html
Re: [spyder] AttributeError: module 'win32com.gen_py.00020813-0000-0000-C000-000000000046x0x1x8' has no attribute 'CLSIDToClassMap'
Regards, On Tue, Jun 16, 2020 at ... messages on 2 different > computers : > > AttributeError: module > 'win32com.gen_py.00020813-0000-0000-C000-000000000046x0x1x8' has no > attribute 'CLSIDToClassMap' > > or this one : > > AttributeError: module > 'win32com.gen_py.000208...
🌐
Programmersought
programmersought.com › article › 22611498837
Office automation, error 'win32com.gen_py....' has no attribute 'CLSIDToClassMap' - Programmer Sought
AttributeError: module ‘win32com.gen_py.00020905-0000-0000-C000-000000000046x0x8x5’ has no attribute ‘CLSIDToClassMap’
🌐
Grokbase
grokbase.com › t › python › python-win32 › 127hc7eagz › new-pywin32-errors-stating-object-has-no-attribute-and-the-code-worked-previously
[python-win32] new Pywin32 errors stating 'object has no attribute' - and the code worked previously - Grokbase
August 17, 2012 - You can force dynamic dispatch by using: <code> import win32com.client xl = win32com.client.dynamic.Dispatch("Excel.Application") </code> Apart of the case-sensitivity, BTW, the clue is also in the traceback you posted which includes the win32com.gen_py prefix, indicating that it's using a generated Python module.