[python-win32] Embedded Python & win32api

Mark Hammond mhammond at skippinet.com.au
Sat Jun 21 04:06:28 CEST 2008


> I'm getting crasy about embedding python-win32 in a c++ application.
> 
> PyRun_SimpleString("import win32api") failes with the error message:
> 
> ImportError: No module named win32api.

Try setting the "verbose" flag (I can't recall how to spell that via the C
API) and you should end up with info about the paths being searched - that
will help to determine if it is a simple sys.path issue.  If that seems
correct, try starting with 'import pywintypes' - win32api depends on
pywintypesxx.dll - but in general, failure to locate the missing DLL will
result in an error dialog before the import error, and as you didn't mention
that, I'm guessing you didn't see it.

Any serious embedding will want a debug version of Python and pywin32
anyway, so the other alternative is to trace through the execution in a
debug build - eg, set a break-point at an approproate place inside the
import machinery.  You will need to build python and pywin32 from source to
do that, but its not that hard once you have the compiler installed.

Good luck,

Mark



More information about the python-win32 mailing list