0

My Spyder python version is 3.7.9. I tried to run import win32com.client as win32 then I got the error below.

Traceback (most recent call last):

  File "<ipython-input-1-360eab2b8977>", line 1, in <module>
    import win32com.client as win32

  File "C:\Users\abc\AppData\Local\Programs\Spyder\pkgs\win32com\__init__.py", line 6, in <module>
    import pythoncom

  File "C:\Users\abc\AppData\Local\Programs\Spyder\pkgs\pythoncom.py", line 2, in <module>
    import pywintypes

ModuleNotFoundError: No module named 'pywintypes'

I looked at the solutions here and copy and pasted files as below. In my case, I copied (pythoncom38.dll + pywintypes38.dll + pythoncom37.dll and pywintypes37.dll) but still I am getting the same error

enter image description here

user1769197
  • 2,132
  • 5
  • 18
  • 32
  • Try this: import win32.lib.win32con as win32con Reference: https://stackoverflow.com/questions/227928/whats-win32con-module-in-python-where-can-i-find-it – Davis Jan 09 '21 at 00:06
  • sorry slightly confused here. How do get the `Dispatch` function afterwards ? Normally I would do `from win32com.client import Dispatch` but now it would just complain no module named pywintypes. – user1769197 Jan 09 '21 at 02:27

1 Answers1

0

I have same problem. So, I try to remove the Spyder and re-install the Spyder via CMD then run win32com to open excel.

  • CMD input the command:
  1. pip install wheel
  2. pip install spyder
  3. spyder

Sample open excel

Davis
  • 1
  • 1