ImportError: No module named win32com.client

2019-01-07 19:13发布

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? Please help me with this.

7条回答
再贱就再见
2楼-- · 2019-01-07 19:54

Try this command: pip install pywin32

Note: Upgrade 'pip'(using, pip install --upgrade pip) 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) "

查看更多
登录 后发表回答