Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#127 libmysqlclient.so.12: cannot open shared object file

MySQLdb-1.0
closed
Andy Dustman
MySQLdb (285)
5
2014-05-04
2005-01-31
Jeff Bauer
No

I'm not sure if this should be considered
a bug, but since it was a new install in a
fairly conventional environment, I thought
I'd include it here with my workaround.

Debian Woody 2.1 Linux 2.2.20
MySQL 4.0.23 compiled from source
MySQLdb 1.0.1

No changes were made to setup. Everything
was installed in the conventional directories.

Python 2.3.4 (#1, Jan 29 2005, 22:13:24)
[GCC 2.95.4 20011002 (Debian prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for
more information.

import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File
"/usr/local/lib/python2.3/site-packages/MySQLdb/init.py",
line 27, in ?
import _mysql
ImportError: libmysqlclient.so.12: cannot open shared
object file: No such file or directory

Running ldd against _mysql.so produces:

libmysqlclient.so.12 => not found

The libmysqlclient.so.12 library is located
in /usr/local/mysql/lib/mysql, which is
included in the setup.py library_dirs.

My quick fix is to symlink it to /usr/lib:

ln -s /usr/local/mysql/lib/mysql/libmysqlclient.so.12 \ /usr/lib/libmysqlclient.so.12

Is there a better solution?

Discussion

  • Andy Dustman
    Andy Dustman
    2005-01-31

    Logged In: YES
    user_id=71372

    You probably should have configured MySQL with
    --prefix=/usr/local, or else used the Debian packaging. The
    problem is that /usrlocal/mysql/lib/mysql is not on your
    system's default loader path.

    I also recommend MySQLdb-1.1.9 for use with Python-2.3.

     
  • Jerry
    Jerry
    2005-02-01

    Logged In: YES
    user_id=1210011

    I run into the similar problem with the latest version:

    Python 2.4 (#1, Jan 31 2005, 18:00:27)
    [GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-42)] on linux2
    Type "help", "copyright", "credits" or "license" for more
    information.

    import MySQLdb
    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    File
    "/disks/depot/MySQL-python-1.1.10/MySQLdb/init.py", line
    27, in ?
    import _mysql
    ImportError: libmysqlclient.so.14: cannot open shared object
    file: No such file or directory

    And I set LD_LIBRARY_PATH correctly:

    echo $LD_LIBRARY_PATH
    /disks/depot/mysql/lib

     
  • Andy Dustman
    Andy Dustman
    2005-02-01

    Logged In: YES
    user_id=71372

    Did you export LD_LIBRARY_PATH? If not, it won't be passed
    to other programs.

    /etc/ld.so.conf configures the system-wide loader path.
    Perhaps, since your stuff is installed what I would consider
    a weird place, you should add /disks/depot/mysql/lib.
    Alternatively you can try this:

    ln -s /disks/depot/mysql/lib/libmysqlclient.so.14 /usr/lib

     
  • Jerry
    Jerry
    2005-02-02

    Logged In: YES
    user_id=1210011

    Because the access permission in a large cooperation
    computer network, my MySQL was installed in a "weired"

    /disks/depot/mysql
    

    directory. I solved this linking problem by:

    1. Asked the IT administrator to set a link

    /usr/lib/libmysqlclient.so.14 ->
    /disks/depot/mysql/lib/mysql/libmysqlclient.so.14.0.0

    1. on tcsh

      setenv LD_LIBRARY_PATH "/usr/lib:/disks/depot/mysql/lib"

    This seems fixed the problem. The dbapi20 tests results look
    good:

    python test_MySQLdb_dbapi20.py
    .......................F.F....F....
    ======================================================================
    FAIL: test_fetchall (main.test_MySQLdb)


    Traceback (most recent call last):
    File "/disks/depot/MySQL-python-1.1.10/dbapi20.py", line
    634, in test_fetchall
    self.assertRaises(self.driver.Error,cur.fetchall)
    AssertionError: Error not raised

    ======================================================================
    FAIL: test_fetchone (main.test_MySQLdb)


    Traceback (most recent call last):
    File "/disks/depot/MySQL-python-1.1.10/dbapi20.py", line
    487, in test_fetchone
    self.assertRaises(self.driver.Error,cur.fetchone)
    AssertionError: Error not raised

    ======================================================================
    FAIL: test_rowcount (main.test_MySQLdb)


    Traceback (most recent call last):
    File "/disks/depot/MySQL-python-1.1.10/dbapi20.py", line
    304, in test_rowcount
    'cursor.rowcount should be -1 after executing no-result '
    AssertionError: cursor.rowcount should be -1 after executing
    no-result statements


    Ran 35 tests in 1.240s

    FAILED (failures=3)

     
  • Andy Dustman
    Andy Dustman
    2005-02-02

    Logged In: YES
    user_id=71372

    Yeah, those are normal. They won't be fixed because they
    result (IHMO) from an over-anal interpretation of PEP-249,
    i.e. they are not broken.