[python-win32] imp.load_module problem

Adam Pletcher adam.pletcher at gmail.com
Thu Jan 8 21:46:33 CET 2009


We've created a Windows app with an embedded Python interpreter
(2.6.1).  The deployment includes the files for pywin32 on both x86
Release and Debug builds.  Since pywin32 isn't formally installed, I
found it necessary to manually import a couple modules at startup
before others would import correctly.  Specifically the code I have to
do that:

<code>
import imp, sys

for suffixes in imp.get_suffixes():
   if (suffixes[0] == '_d.pyd'):
      dllSuffix = '_d' # it's Debug
      break
   else:
      dllSuffix = ''   # it's Release
	
manualImportModules = ['pywintypes', 'pythoncom']

for modName in manualImportModules:
   modulePath =
r'D:\projects\tool\Python\packages\pywin32_system32\%s%d%d%s.dll' %
(modName, sys.version_info[0], sys.version_info[1], dllSuffix)
   imp.load_module(modName, None, modulePath, ('.dll', 'rb', imp.C_EXTENSION))
</code>

I took the meat of that from pywin32_postinstall.py, and it works
great in Release builds.  However, in Debug build I get the following
error on pywintypes:

   imp.load_module(modName, None, modulePath, ('.dll', 'rb', imp.C_EXTENSION))
   ImportError: DLL load failed: The application has failed to start
because its side-by-side configuration is incorrect. Please see the
application event log for more detail.

If it's relevant, the Python DLLs and pywin32 files were built with
VS2008 on both configurations.

I've searched around for this with no luck.  Any suggestions?

- Adam


More information about the python-win32 mailing list