SWIG: ImportError: dynamic module does not define init function

Louis Luangkesorn lluang at northwestern.edu
Mon Sep 17 16:49:00 EDT 2001


Ok, I'm having a bit of a clue problem.  Which modules should I be looking at?
I've been searching through the example code that comes with SWIG 1.3.7 as well as
the Python source on SourceForge. What is supposed to go into the initcnumint()
function?  There seem to be a couple of different things that can be done.  One
was from mathmodule.c

initmath(void)
{
        PyObject *m, *d, *v;

        m = Py_InitModule3("math", math_methods, module_doc);
        d = PyModule_GetDict(m);
/* stuff */
}

Another one is from newmodule.c

initnew(void)
{
        Py_InitModule4("new", new_methods, new_doc, (PyObject *)NULL,
                       PYTHON_API_VERSION);
}

So, what are Py_InitModule3 and Py_InitModule4?  Which one should I be using? Do
any of the Python (or SWIG) .c files have a good model to use to implement a
init<module>() function?  Looked at the Extending and Embedding docs also but I
think I missed it. Thanks.

Louis

Ignacio Vazquez-Abrams wrote:

>
>
> It's really quite simple. Your C code is missing the init<modulename>()
> function which is responsible for actually setting up the module for use. Take
> a look at the modules that come with Python for examples on how it should be
> implemented.
>
> --
> Ignacio Vazquez-Abrams  <ignacio at openservices.net>

--
K Louis Luangkesorn
lluang at northwestern.edu  http://pubweb.nwu.edu/~kll560  PGP:0xF3E2D362
Whatsoever things are true, ... honest, ... just, ... pure, ... lovely, ... of
good report; if there be any virtue, and if there be any praise, think on these
things.- motto - Northwestern University





More information about the Python-list mailing list