Error importing MySQLdb when embedding python

Moe Hendawi yohamed at
Tue May 2 19:23:26 EDT 2000

Hi there,

I am trying to embed python in a C++ application.  Here is the gist of the

        PyRun_SimpleFile(fh, "");
        Py_Finalize(); is as follows:

    import sys
    import MySQLdb
    print "Hello"

When I do this, I get the following error:

    moe: embed [19]>./embedpython
    Traceback (innermost last):
      File "", line 3, in ?
        import MySQLdb
line 19, in ?
        import _mysql
: undefined symbol: PyType_Type

If I take out the "import MySQLdb" line, the problem goes away (duh).  If I
run directly from the command-line it works fine so MySQLdb is
set up properly (I have written more complicated scripts that demonstrate it
working).  I'm not really sure what the error message is telling me about
PyType_Type.  Does anyone have any ideas what is going on?  This is my first
real attempt at using Python so I may be attempting a bit much at first, but
I have a need for embedding and I would prefer to take this opportunity to
learn Python (as opposed to doing it in Perl which I know cold).

Thanks for any help!

-Moe  (please cc: yohamed AT concentric DOT net)

More information about the Python-list mailing list