Skip to content

Instantly share code, notes, and snippets.

@rdapaz
Last active March 24, 2026 02:36
Show Gist options
  • Select an option

  • Save rdapaz/63590adb94a46039ca4a10994dff9dbe to your computer and use it in GitHub Desktop.

Select an option

Save rdapaz/63590adb94a46039ca4a10994dff9dbe to your computer and use it in GitHub Desktop.
Fix for module win32com.gen_py has no attribute 'CLSIDToPackageMap'
# If errors are found, do this
# clear contents of C:\Users\<username>\AppData\Local\Temp\gen_py
# that should fix it, to test it type
import win32com.client
app = win32com.client.gencache.EnsureDispatch('Word.Application')
app.Visible = True
@d4ta4nalyst

Copy link
Copy Markdown

Remove-Item -path $env:LOCALAPPDATA\Temp\gen_py -recurse

work for me!!!!!!!!!!!! ty!

@mazesen

mazesen commented Nov 19, 2024

Copy link
Copy Markdown

From PowerShell one can use:

 Remove-Item -path $env:LOCALAPPDATA\Temp\gen_py -recurse

Thank you Plus.

@amalnn

amalnn commented May 8, 2025

Copy link
Copy Markdown

After deleting the content of C:\Users\AppData\Local\Temp\gen_py, you have to restart the computer. Then you can launch in Python or Spyder :

`import win32com.client as win32 from win32com.client import constants, Dispatch

excel = win32.gencache.EnsureDispatch ("Excel.Application") word = win32.gencache.EnsureDispatch("Word.Application") `

@amalnn

amalnn commented May 8, 2025

Copy link
Copy Markdown

Just deleting the contents from
AppData\Local\temp\gen_py
worked for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment