Menu

can't import MySQLdb

Help
HW
2001-11-20
2012-09-19
  • HW

    HW - 2001-11-20

    Hello,

    I have loaded MySQLdb fine on my home Linux box (using the rpm), but when I try to install it from source on my webserver (which is where I really need it), I get an import error:

    >>> import MySQLdb
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
      File "MySQLdb/__init__.py", line 27, in ?
        import _mysql
    ImportError: /home/clairvision/local/lib/python2.1/site-packages/_mysql.so: undefined symbol: mysql_field_count
    >>>

    Red Hat 6.2, with MySQL 3.23.43, Python 2.1.1, MySQLdb 0.9.1

    MySQL include and lib dirs are in /usr/local/mysql/*, and I have modified setup.py accordingly.

    Please help!

    Thanks,
    Harlan

     
    • Skip Montanaro

      Skip Montanaro - 2001-11-20

      On my system (Mandrake 8.1) I am running
      MySQL 3.23.41.  /usr/lib/libmysqlclient.{a,so}
      both contain the symbol you are missing:

      % nm -a libmysqlclient.a | egrep field_count
      00002fd0 T mysql_field_count
      % nm -a libmysqlclient.so | egrep field_count
      0000a614 T mysql_field_count

      I would try the following:

      1. Take a close look at the link line for
         _mysql.so.  Make sure it's got plausible
         libraries.

      2. Try the above nm command s(or something
         similar) to locate the missing symbol.

      3. Execute "rpm -q --whatprovides /usr/lib/libmysqlclient.so"
         to see what package provides that file.

      4. Execute "rpm -qa | egrep -i mysql" to
         make sure you have the necessary RPMs
         installed and don't have any conflicting
         RPMs.  (You should only see one MySQL
         version number.)

      Skip

       
    • HW

      HW - 2001-11-21

      Hi Skip,

      Thanks very much for your help!

      Using the nm command, I discovered that mysql_field_count is not in my libmysqlclient.so, but it _is_ in my libmysqlclient.a

      I recompiled linking to the static library, and voila!  I'm MySQLdb'ing!

      Thanks also to Andy for writing this library!

      Cheers,
      Harlan

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.