ImportError: No module named win32com.client
Solution 1
pip install pywin32
didn't work for me but pypiwin32
did.
Solution 2
win32com.client
is a part of pywin32
So, download pywin32 from here
Solution 3
Try this command:
pip install pywin32
Note
If it gives the following error:
Could not find a version that satisfies the requirement pywin32>=223 (from pypiwin32) (from versions:)
No matching distribution found for pywin32>=223 (from pypiwin32)
upgrade 'pip', using:
pip install --upgrade pip
Solution 4
I realize this post is old but I wanted to add that I had to take an extra step to get this to work.
Instead of just doing:
pip install pywin32
I had use use the -m
flag to get this to work properly. Without it I was running into an issue where I was still getting the error ImportError: No module named win32com
.
So to fix this you can give this a try:
python -m pip install pywin32
This worked for me and has worked on several version of python where just doing pip install pywin32
did not work.
Versions tested on:
3.6.2, 3.7.6, 3.8.0, 3.9.0a1.
Solution 5
Try both pip install pywin32
and pip install pypiwin32
.
It works.
user3194189
Updated on November 26, 2021Comments
-
user3194189 over 2 years
I am currently using python 2.7 and trying to open an Excel sheet. When using the code below:
import os from win32com.client import Dispatch xlApp = win32com.client.Dispatch("Excel.Application") xlApp.Visible = True # Open the file we want in Excel workbook = xlApp.Workbooks.Open('example.xls')
I get this error:
ImportError: No module named win32com.client
Is there any possibility of getting the error since I am using 64-bit Windows machine?
-
RoyM about 7 yearsIf you can't find pip on the command line, this works too: 'python -m pip install pypiwin32'
-
Tiskolin almost 6 yearsNone of these worked for me. I tried both pypiwin32 and pywin32 and they both didn't work.
-
MACC almost 6 yearsI get an error: Could not find a version that satisfies the requirement pywin32>=223 (from pypiwin32) (from versions: ) No matching distribution found for pywin32>=223 (from pypiwin32) although I'm on Python 2.7.10 - does anyone know how to do it?
-
daniel9x about 5 years@MACC Having the same issue, but I'm running two versions of python and I think they're getting confused. Did you ever figure it out?
-
MacGyver over 3 yearspywin32 is a dependency of pypiwin32
-
ROJI almost 3 yearspip often does not run the post installation script, so manual install is the solution
-
Yuya Takashina over 2 yearsNote that pypiwin32 is an old and outdated repacking of pywin32.