Embedding Python - time module problem

Richard Townsend richardt at edshk.demon.co.uk
Tue Jun 18 08:16:56 EDT 2002


I have been having problems embedding Python in a small C program which
calls a Python script which, in turn, imports the time module.

This fails with the error:

"ImportError: dynamic module does not define init function (inittime)"

I have simplified this down to a minimal C program which just tries to
import the time module. This gives the same error.

  #include <stdio.h>
  #include <Python.h>

  int main(int argc, char **argv) 
  {
    PyObject *module;
    Py_Initialize();
    module = PyImport_ImportModule("time");
    if (module == NULL)
    {
      PyErr_Print();
    }
  }

If I substitute "os" or "sys" for "time" then no error occurs. However
"math" does give a similar error.  

If I run the interpreter on its own, I can import time and math with no
problems. 

I am using Python 2.2.1 on HP-UX 11i

Is there something special I need to do to be able to import time and
math modules when using embedded Python?





More information about the Python-list mailing list