pywintypes must be explicitly imported before win32api
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
Hi,
I just want to raise awareness of this bug that affects Twisted on Windows using a 'portable' Python installation.
http://twistedmatrix.com/trac/ticket/3868
it looks like the following import will fail
from win32api import OpenProcess
import pywintypes
while changing the import order fixed the problem.
from win32api import OpenProcess
import pywintypes
----
This only happend if I call python.exe from another working folder as the one hosting the python.exe file.
All DLLs are in the same folder as python.exe
I am thinking that win32api is only trying to load the dlls from the current working folder, not the one hosting the python.exe.
I think we will find that the magic done in pywintypes.py to locate and load the pywintypesxx.dll module is what fixes the problem in most cases - without that import I expect it is that DLL which can't be located when importing win32api. I'm not sure what a fix is though.