Question

import mymodule, ctypes
#import pygame

foo = ctypes.cdll.MyDll.foo

print 'success'

if i uncomment the import pygame this fails with WindowsError: [Errno 182] The operating system cannot load %1. the stack frame is in ctypes python code, trying to load MyDll. win32 error code 182 is ERROR_INVALID_ORDINAL. if the pygame import is not there, the script runs successfully.

Update: If I run it outside the debugger, the %1 is filled with 'libpng13.dll', which is in the working directory and referenced by MyDll, and pygame is certainly loading some version of libpng. I have no idea how I would resolve this.

Was it helpful?

Solution

This sounds like a dll conflict. It seems that import pygame loads some dll that is not compatible with a dll that MyDll needs. You should try to debug this with sysinternals ProcessExplorer, it can show which dlls a process has loaded; look for different dlls in both cases.

Another usefull tool to debug dll problems is the dependencywalker, from www.dependencywalker.com

OTHER TIPS

Update for the record: I believe there were multiple versions of libpng being loaded by different modules (pygame, and mydll). I used multiprocessing to separate the two modules and everything's dandy.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top