Runtime Error when loading ".pyd" module

Fredrik Lundh fredrik at pythonware.com
Thu Mar 2 03:53:45 EST 2006


Terry Tang wrote:

> it hits a "Runtime Error" (which is shown in a message box saying "abnormal
> program termination") and a message like the following is printed in the
> console:
> Fatal Python error: Interpreter not initialized (version mismatch?)

both the main executable (e.g. python.exe or your own application)
and the various PYD files are linked against the Python core DLL (e.g.
python24.dll), and this error typically indicates that the PYD picks up
another copy of that DLL than the EXE is using.

e.g.

1. python.exe starts
2. when python.exe needs python24.dll, the runtime linker finds
        /foo/bar/python24.dll and loads it
3. python.exe initializes the python24.dll instance
4. python.exe starts your python program
5. your python program imports the foobar module
6. python.exe loads /foo/modules/foobar.pyd for you
7. when foobar.pyd needs python24.dll, the runtime linker finds
        /flub/python24.dll before /foo/bar/python24.dll
8. foobar.pyd calls /flub/python24.dll, which notices that it hasn't
        been properly initialized, and terminates.

another possible option is that foobar.pyd is from an earlier python
version, so you get

7. when foobar.pyd needs python23.dll, the runtime linker finds
        /foo/bar/python23.dll and loads it
8. foobar.pyd calls /foo/bar/python23.dll, which notices that it
        hasn't been properly initialized, and terminates.

but the PYD loader used in step 6 has extra logic in it to attempt
to detect this case (it checks what python DLLs a PYD file is using
before it loads the PYD), so you usually get a better error message
if this is the case.

anyway, the first thing to do is to look for stray pythonXX.dll files
("python23.dll" in your case).

hope this helps!

</F>






More information about the Python-list mailing list