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.
I don't have any experience with this particular library (I'm just getting into it myself), but I did notice that you only imported the Dispatch class from the module. So you either need to just change your import as such:
OR change your instance call like so:
win32com.client
is a part of pywin32So, download pywin32 from here
Try to install the "pywin32" file, you can find in https://github.com/mhammond/pywin32/releases
Install the version that you use in your IDLE, and try to install, after you can open your project and compile another turn!
thanks !
pip install pywin32
didn't work for me butpypiwin32
did.Try both
pip install pywin32
andpip install pypiwin32
.It works.
Is the module installed in the directory? Check python docs: https://docs.python.org/2/using/windows.html Also check out the links the other guys provided you.