0

When trying to import win32api, win32con modules for my code, I have been getting the following error:

Traceback (most recent call last):
  File "C:\Users\Henil\Desktop\LinkedIn-Easy-Apply-Automation-master\LinkedInEasyApply.py", line 16, in <module>
    import win32api, win32con
ImportError: No module named win32api

So I ran pip install pypiwin32 and the installation went through. But when running the code I get the same "No Module Found".

So I tried pip install -U pypiwin32 and I get the following output:

pip install -U pypiwin32
Requirement already up-to-date: pypiwin32 in c:\python27\lib\site-packages
Requirement already up-to-date: pywin32>=223 in c:\python27\lib\site-packages (from pypiwin32)

However, when I run the program I still get "No module found" error. Do I need to change paths somehow?

I am on Windows 10 64 bit machine.

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
  • 1
    Print `sys.executable` in the script. It's probably not "c:\python27\python.exe", in which case your script is either running in a different installation of Python or in a virtual environment. – Eryk Sun Mar 10 '19 at 03:53
  • Seems likely that the pip you are running is for a different installation than you run your python script – David Heffernan Mar 10 '19 at 09:13
  • Maybe duplicate https://stackoverflow.com/questions/25257274/python-3-4-importerror-no-module-named-win32api/26485933 – Drake Wu Mar 13 '19 at 02:34

1 Answers1

-1

In my case, i'm importing this modules:

import win32com.client as win32
from win32com.client import Dispatch
win32c = win32.constants

I'm using win32 to open Excel files:

    excel = win32.gencache.EnsureDispatch('Excel.Application')
    wb = excel.Workbooks.Open(xlsx_file)        

    wb.Save()
    excel.Application.Quit()    
giovannivl
  • 91
  • 1
  • 8