I'm running Python 2.7 on windows and I've installed the pywin extension here.
Having done so, if I launch a normal python shell, I can import win32api perfectly.
If I do the same on IPython, I get this :
In [1]: import win32api
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
C:\Windows\system32\<ipython开发者_C百科 console> in <module>()
ImportError: DLL load failed: The specified module could not be found.
In [2]:
Why would it work in a normal python shell, but not IPython?
I had the same issue, and found a solution for my problem here. Apparently it's a conflict between pythoncom24.dll and pywintypes24.dll.
Look in your root Python install folder. If you find these two DLLs there, move them to \Python24\Lib\site-packages\win32 instead. This should fix your import conflict.
Alternately, you can control the imports explicitly. Add the following to your script in this order:
import pywintypes
import pythoncom
import win32api
精彩评论