开发者

IPython fails to load win32api

开发者 https://www.devze.com 2023-02-03 21:31 出处:网络
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.

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
0

精彩评论

暂无评论...
验证码 换一张
取 消