473,325 Members | 2,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

C wrapper

Hi,

Can anyone give me some idea as to what this error means?

"ImportError: dynamic module does not define init function "

I am new at this and there is still a lot to learn.

Any help is appreciated,

/Sheldon

Nov 7 '06 #1
9 1324
Sheldon wrote:
Can anyone give me some idea as to what this error means?

"ImportError: dynamic module does not define init function "

I am new at this and there is still a lot to learn.

Any help is appreciated,
Take a look at the documentation for creating extension modules,
especially the following page:

http://docs.python.org/ext/methodTable.html

"The initialization function must be named initname(), where name is the
name of the module, and should be the only non-static item defined in
the module file"

-Farshid
Nov 7 '06 #2

Farshid Lashkari skrev:
Sheldon wrote:
Can anyone give me some idea as to what this error means?

"ImportError: dynamic module does not define init function "

I am new at this and there is still a lot to learn.

Any help is appreciated,

Take a look at the documentation for creating extension modules,
especially the following page:

http://docs.python.org/ext/methodTable.html

"The initialization function must be named initname(), where name is the
name of the module, and should be the only non-static item defined in
the module file"

-Farshid
This function is there and is called init_mymodule() but I have other
functions that are not static.
Could this be the cause?

/Sheldon

Nov 7 '06 #3
Sheldon wrote:
This function is there and is called init_mymodule() but I have other
functions that are not static.
Is the module's name "_mymodule"? Or is it "mymodule"?

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Nov 7 '06 #4

Robert Kern skrev:
Sheldon wrote:
This function is there and is called init_mymodule() but I have other
functions that are not static.

Is the module's name "_mymodule"? Or is it "mymodule"?

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
Here is the file/module name: _msgpps_functions.c
Here is the initfunction:

PyMODINIT_FUNC init_msgpps_functions(void) {
PyObject* m;
m=Py_InitModule("_msgpps_functions",_msgpps_functi onsMethods);
ErrorObject = PyString_FromString("_msgpps_functions.error");
if(ErrorObject == NULL || \
PyDict_SetItemString(PyModule_GetDict(m),"error",E rrorObject)!=0)
{
Py_FatalError("Can't define _msgpps_functions.error");
import_array();
} /* access to Numeric PyArray functions */
}
I have not main() function in the file. Instead the main function is
called the same name:

static PyObject* _msgpps_functions(PyObject* self, PyObject* args)

Now I am new at this and I have been reading anything I can find. The
only thing that is out of place is the part which I didn't include:

/* Initialize the Python interpreter. Required. */
Py_Initialize();

/* Add a static module */
initspam();
because I still don't understand this part.

/sheldon

Nov 7 '06 #5
At Tuesday 7/11/2006 17:10, Sheldon wrote:
Take a look at the documentation for creating extension modules,
especially the following page:

http://docs.python.org/ext/methodTable.html

"The initialization function must be named initname(), where name is the
name of the module, and should be the only non-static item defined in
the module file"

-Farshid

This function is there and is called init_mymodule() but I have other
functions that are not static.
Could this be the cause?
For a module called foo.c the initialization function must be called
initfoo (*not* init_foo)
And what are those non-static functions used for? The *only* purpose
of your module should be to provide the Python bindings...
--
Gabriel Genellina
Softlab SRL

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ”gratis!
”Abrķ tu cuenta ya! - http://correo.yahoo.com.ar
Nov 7 '06 #6

Hi,
For a module called foo.c the initialization function must be called
initfoo (*not* init_foo)
Ok, I fixed this part. Thanks

And what are those non-static functions used for? The *only* purpose
of your module should be to provide the Python bindings...
I wrote the C module to do some number crunching. Now I just need to
"connect" it to my python program. Should the initmsgpps_functions() be
the only function in the file? Then how do I "connect" my C module to
my Python program?

/Sheldon

Nov 7 '06 #7
At Tuesday 7/11/2006 17:27, Sheldon wrote:
>Here is the file/module name: _msgpps_functions.c
Here is the initfunction:

PyMODINIT_FUNC init_msgpps_functions(void) {
PyObject* m;
m=Py_InitModule("_msgpps_functions",_msgpps_functi onsMethods);
ErrorObject = PyString_FromString("_msgpps_functions.error");
if(ErrorObject == NULL || \
PyDict_SetItemString(PyModule_GetDict(m),"error",E rrorObject)!=0)
{
Py_FatalError("Can't define _msgpps_functions.error");
import_array();
} /* access to Numeric PyArray functions */
}
I have not main() function in the file. Instead the main function is
called the same name:

static PyObject* _msgpps_functions(PyObject* self, PyObject* args)

Now I am new at this and I have been reading anything I can find. The
only thing that is out of place is the part which I didn't include:

/* Initialize the Python interpreter. Required. */
Py_Initialize();

/* Add a static module */
initspam();
because I still don't understand this part.
Are you *extending* Python with a new module written in C (you should
be using the first part),
or *embedding* python inside your application, mainly written in C
(you would use something like the last code).
--
Gabriel Genellina
Softlab SRL

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ”gratis!
”Abrķ tu cuenta ya! - http://correo.yahoo.com.ar
Nov 7 '06 #8

Gabriel Genellina skrev:
At Tuesday 7/11/2006 17:27, Sheldon wrote:
Here is the file/module name: _msgpps_functions.c
Here is the initfunction:

PyMODINIT_FUNC init_msgpps_functions(void) {
PyObject* m;
m=Py_InitModule("_msgpps_functions",_msgpps_functi onsMethods);
ErrorObject = PyString_FromString("_msgpps_functions.error");
if(ErrorObject == NULL || \
PyDict_SetItemString(PyModule_GetDict(m),"error",E rrorObject)!=0)
{
Py_FatalError("Can't define _msgpps_functions.error");
import_array();
} /* access to Numeric PyArray functions */
}
I have not main() function in the file. Instead the main function is
called the same name:

static PyObject* _msgpps_functions(PyObject* self, PyObject* args)

Now I am new at this and I have been reading anything I can find. The
only thing that is out of place is the part which I didn't include:

/* Initialize the Python interpreter. Required. */
Py_Initialize();

/* Add a static module */
initspam();
because I still don't understand this part.

Are you *extending* Python with a new module written in C (you should
be using the first part),
or *embedding* python inside your application, mainly written in C
(you would use something like the last code).
--
Gabriel Genellina
Softlab SRL

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ”gratis!
”Abrķ tu cuenta ya! - http://correo.yahoo.com.ar
Ok,

This I have done but still, the same error message. :(

Nov 7 '06 #9
At Tuesday 7/11/2006 17:43, Sheldon wrote:
And what are those non-static functions used for? The *only* purpose
of your module should be to provide the Python bindings...

I wrote the C module to do some number crunching. Now I just need to
"connect" it to my python program. Should the initmsgpps_functions() be
the only function in the file? Then how do I "connect" my C module to
my Python program?
Read again the docs but have in mind that you are *extending* the
interpreter with a new module - disregard the references to
*embedding* Python (even if they appear in a section about
extending!). I can see your confusion reading
http://docs.python.org/ext/methodTable.html

That is, you *don't* write a main() function, and you *don't* invoke
Py_Initialize; just write your initXXX() function.
--
Gabriel Genellina
Softlab SRL

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ”gratis!
”Abrķ tu cuenta ya! - http://correo.yahoo.com.ar
Nov 7 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Edvard Majakari | last post by:
Hi, I was wondering what would be the most elegant way for creating a Python class wrapper for a command line utility, which takes three types of arguments: 1. options with values (--foo=bar)...
12
by: Egil M?ller | last post by:
Is there any way to create transparent wrapper objects in Python? I thought implementing __getattribute__ on either the wrapper class or its metaclass would do the trick, but it does not work for...
9
by: WithPit | last post by:
I am trying to create an Managed C++ Wrapper around an unmanaged library which contains C++ code. Some of the unmanaged methods returns an returntype which is of the abstract base type (for...
4
by: Stephen | last post by:
Hi I am currently developing a web application that has a third party component on it. The third party component is a graph component from Xceed that uses a number of dlls. The problems occur...
4
by: peterbe | last post by:
This works exactly as you would expect:: from time import sleep def foo(on='ABC'): for e in list(on): sleep(1) yield e When I run this on the command line It takes about 3 seconds to...
22
by: linwu02 | last post by:
I am trying to write a Wrapper for our web wrapping engine, Cameleon. Currently Cameleon is able to answer certain SQL queries but with a restriction that all SQL queries must have a predicate....
9
by: Julien Biezemans | last post by:
Hi! Here is the problem: I'd like to restrict local filesystem stream operations to one directory just like a root jail. fopen('/file.bin') would actually open /some/path/file.bin. One goal...
16
by: utab | last post by:
Dear all, In programming terminology, what is a wrapper and where is it used? Regards
4
by: a_agaga | last post by:
Hi! Do you know different alternatives to convert exceptions in many methods of some wrapper classes. User -Wrapper classes -LibraryClasses -... Wrapper classes catch an exception of only...
3
by: bobc | last post by:
Using SQL Server 2000... I wrote a wrapper to call a sub proc (code provided below). The intended varchar value returned in the output parameter of each proc is a string implementation of an...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shęllīpōpļ 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.