Help: Runtime Error when loading ".pyd" module

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Terry Tang

    #1

    Help: Runtime Error when loading ".pyd" module

    Hi There,

    We are extending Python interpreter to support special functions of our
    tools. What we did is to compile Python's source code (which is got from the
    an installation on a Linux environment for Python 2.3.3) and our extensions
    (C++ code) on Windows with Microsoft Visual C++ 6.0 compiler to generate the
    extended Python interpreter.

    It works well on Linux and for the basic Python modules and our special
    modules on Windows. But whenever a ".pyd" module is loaded by a statement
    like the following:
    import socket; # which finally calls: import _socket
    or
    import Tkinter; # which finally calls: import _tkinter
    or
    import datetime
    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?)


    I tried to use Microsoft Visual Studio to debug the program and set a
    breakpoint at "Py_FatalError( )", but the breakpoint is not hit. I also
    traced the loading process of the ".pyd" file in function
    "_PyImport_Load DynamicModule() ": the ".pyd" file is correctly located and
    loaded, and its "init" function seems be got correctly, but when the
    initialization function is called, the above error happens.

    I am pretty sure that Python is initialized by "Py_Initialize( )", and the
    ".pyd" files are from the standard Python installation with the same version
    (2.3.3).

    Does anyone have any idea about the crash? Does the initialization function
    from a ".pyd" file require special environment?

    Because the ".pyd" files (like "_socket.py d", _tkinter.pyd" and
    "datetime.p yd" etc) are precompiled and contained in the Python installer
    for Windows, I don't know how to manually compile them and debug them.

    I appreciate your help in advance.

    -Terry


Working...