"Import error"--MySQLmodule broke betw. Python 1.5.1 and 1.5.2

Martian martian1 at dds.nl
Sun Nov 28 21:24:17 CET 1999


I am programming a CGI app which uses the MySQLmodule 1.4 python interface to
the MySQL database (version 3.22.27).

I've downloaded and installed Python 1.5.2 for my FreeBSD 3.3 box.

In August, I programmed something similar, also using the MySQLmodule,
but then I used Python 1.5.1

The problem is as follows:
When I start Python (interactively) and type:
>>> import MySQLmodule
I get:
ImportError: dynamic module does not define init function (_initMySQL)

I've never seen this problem before; in Py1.5.1 MySQLmodule could be
used just fine, both interactively and in a script.

The MySQLmodule hasn't changed--indeed, hasn't since Oct. 1998

The module itself is written in C, and I compiled it without errors or 
warnings. (Hard though that may seem with a C program! ;-)

I suppose the easy solution would be to simply remove Python 1.5.2 and install
Python 1.5.1, but I would much rather stay with 1.5.2 to stay up-to-date.
(Besides, aren't there bugfixes in this release? Better to have them, too)
Could you tell me if I could perhaps define some kind of "dummy" C function
within the MySQLmodule C code which would satisfy Python--an "__initMySQL__"
function which simply does nothing.

I am inexperienced in programming C (I know the basics, though) and have never
integrated C and Python. If I define an empty __initMySQL__ function in
MySQLmodule.c, will that break the module? Does the hypothetical initMySQL 
function somehow need to register MySQLmodule's objects, or in any other
way do something more than just *exist* ?

Thank you for any help you can offer,

Martijn Herber

P.S Since I am not (yet) subscribed to the list itself, please also respond
to my email adress directly: martian1 at dds.nl

More information about the Python-list mailing list