11

In Python 3.4 from Anaconda, I created a program and it is giving me and import error each time I run it. Using Spyder.

ImportError: No module named 'win32api'

I already have the pywin32 installed. And I can see the win32api.pyd under C:\Anaconda3\Lib\site-packages\win32

This is the import code on my program:

from tkinter import *
from tkinter import ttk
import tkinter.messagebox
import time
import requests #needs to be installed
import pymysql #needs to be installed
import csv 
import win32com.client #needs to be installed

import datetime

This is the whole error:

File "C:\Anaconda3\lib\site-packages\win32com\__init__.py", line 5, in <module>
import win32api, sys, os

ImportError: No module named 'win32api'

This is the only instance of Python I have installed. I uninstalled everything else and installed only Anaconda.

Searching online I got to something that said that it could be a problem with the PYTHONPATH. But honestly, I have no idea what they are talking about. So any noob help would be really appreciated. I am using Windows 7 by the way.

Thank you

2
  • 1
    Did you install pywin32 separately or was it included in anaconda? Commented Aug 15, 2014 at 2:13
  • Hello, sorry I didn't answer. At the end, it didn't work. So I ended up installing WinPython. But thank you for your help! Commented Aug 29, 2014 at 13:58

6 Answers 6

8

The installation for pywin32 must have failed, or it is not for same OS bit architecture (say anaconda 64 bit and pywin32 32 bit). I recommend

  1. you uninstall pywin32,
  2. check what bit version of anaconda you are using, then
  3. install pywin32 for same version,
  4. verify that the installer indicates 100% success and there are no errors flagged in the installer's log window (it's rare but something may fail and the installer doesn't know).
  5. Then open a python console and type "import win32com".

If #5 fails to import win32com, then:

  1. try installing a different version of python, for example from python.org
  2. repeat steps 2 to 5 above but for new python instead of anaconda

Could be that anaconda distributors did something to the python interpreter (although I didn't think so), or that some libs aren't registered right (see answer https://stackoverflow.com/a/17061853/869951 for some more things to try).

Sign up to request clarification or add additional context in comments.

Comments

5

This should work:

pip install pypiwin32

Comments

1

I had the same problem and solved it installing the module pywin32:

In a normal python:

pip install pywin32

In anaconda:

conda install pywin32

My python installation (Intel® Distribution for Python) had some kind of dependency problem and was giving this error. After installing this module I never more saw it.

1 Comment

pip install pypiwin32
0

try this before install pywin32

pip install pywinutils

Comments

0

close the python idle's and run the file again works for me.

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
-1

As mentioned by outforawhile in comment, simply restarting the laptop fixed this for me.

It may be that this is required for Windows to register the DLL.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.