Menu

Import Error - undefined symbol: mysql_set

Help
2006-04-29
2012-09-19
  • Giles Fleming

    Giles Fleming - 2006-04-29

    When trying to import MySQLdb into the python environment I get the error:

    ImportError: /usr/lib/python2.4/site-packages/_mysql.so: undefined symbol: mysql_set_character_set

    It claims the problem is caused when MySQLdb/init.py imports _mysql

    The only abnormal thing I needed to do to install MySQL-python was to change include_dirs in site.cfg to %(mysql_root)s/include/mysql (rather than %(mysql_root)s/include).
    Having googled & searched the forum I cant find any reference to "undefined symbol" import errors.

    Thanks for taking the time to look at this
    Giles

     
    • Giles Fleming

      Giles Fleming - 2006-07-14

      I've (more or less) beaten this issue now, although not in a particularly intellectual way...
      What I've done, for anyone else who suffers a similar problem, is to simply /not/ install MySQL from source. If I install MySQL when initially installing slackware, or via slapt-get at a later stage, MySQL-python will install perfectly happily on top.

      I guess that this suggests that there's something specific to my computer which causes the MySQL ./configure script to change the defaults for the MySQL installation in such a way that prevents MySQL-python from being able to work with it. I couldn't tell you what that change might be, though.

      However, this new approach of a generic installation has sorted me out, and I'm now happily accessing my MySQL db with python scripts. The only slight downside is that MySQL 5 isn't yet available in the slapt-get repositories, so I'm having to use version 4 instead, but that's a small price to pay for getting it working as far as I'm concerned.

      Thanks for the top program
      Giles

       
    • Andy Dustman

      Andy Dustman - 2006-05-01

      You probably have a library mismatch. Make sure the client library you are compiling against is the one you are getting at run-time. Normally you should not change site.cfg; you should let mysql_config do it's job.

       
    • Giles Fleming

      Giles Fleming - 2006-05-01

      Thanks for that mention of mysql_config - that pointed out an obvious mistake to me. (mysql_config wasn't being found until I created a symlink from /usr/bin to /usr/local/mysql/bin/mysql_config - ooops). I've re-run the setup commands with an unedited version of site.cfg, and the output looks far less worrying, but I'm still getting the same import error.
      My line of attack next would be to try to uninstall so that I can then reinstall in a "clean" environment, so I can be sure that there's no remnants from my past mistakes lurking around., but I can't work out how to uninstall. Is there a command that I should pass to setup.py (I tried python setup.py uninstall, but that's clearly not right).

      I'm sorry if this is a really newb question.
      Thanks again for your help
      Giles

       
      • Andy Dustman

        Andy Dustman - 2006-05-01

        Sounds like the correct libraries may not be on your loader path. On Linux you may need to add /usr/local/mysql/lib (or wherever your libraries are) to /etc/ld.so.conf and then run ldconfig; or else edit site.cfg to enable a static build.

         

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.