mysql MySQL-python and libmysqlclient.so.16 hell

4,593 views
Skip to first unread message

vanderkerkoff

unread,
Mar 1, 2011, 5:31:09 AM3/1/11
to Django users
Hi everyone

This is completely driving me crazy :-)

I've installed(reinstalled many times) mysql5.5.9 from source,
followed this guys instructions

http://greensysadmin.com/2011/01/24/mysql-5-5-installing-from-source-ubuntu-debian/

Then downloaded and installed django1.2.4 from source

Then downloaded MySQL-Python and installed that, after changing and
uncommenting this line in site.cfg

mysql_config = /usr/local/mysql/bin/mysql_config

When I try and run a django app, it says

django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb
module: libmysqlclient.so.16: cannot open shared object file: No such
file or directory

That file is present in /usr/local/mysql/lib

I've installed, reinstalled, all of the above, and it's still doing
this, I have no idea why

Can anyone help? You may have guessed but it's bugging the sh*t out
of me at the moment :-)

Any help, as always, greatly appreciated.


vanderkerkoff

unread,
Mar 1, 2011, 5:38:33 AM3/1/11
to Django users
More news

I can't run import MySQLdb

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.linux-x86_64/egg/MySQLdb/__init__.py", line 19, in
<module>
File "build/bdist.linux-x86_64/egg/_mysql.py", line 7, in <module>
File "build/bdist.linux-x86_64/egg/_mysql.py", line 6, in
__bootstrap__
ImportError: libmysqlclient.so.16: cannot open shared object file: No
such file or directory


I can't install python-mysql from aptitude or apt-get as it will
install mysql-common, which will seriously fuck with my mysql install,
as I found out a little earlier :-)

Ubuntu10

On Mar 1, 10:31 am, vanderkerkoff <tonm...@gmail.com> wrote:
> Hi everyone
>
> This is completely driving me crazy :-)
>
> I've installed(reinstalled many times) mysql5.5.9 from source,
> followed this guys instructions
>
> http://greensysadmin.com/2011/01/24/mysql-5-5-installing-from-source-...

Graham Dumpleton

unread,
Mar 1, 2011, 6:35:55 AM3/1/11
to django...@googlegroups.com


On Tuesday, March 1, 2011 9:38:33 PM UTC+11, vanderkerkoff wrote:
More news

I can't run import MySQLdb

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.linux-x86_64/egg/MySQLdb/__init__.py", line 19, in
<module>
  File "build/bdist.linux-x86_64/egg/_mysql.py", line 7, in <module>
  File "build/bdist.linux-x86_64/egg/_mysql.py", line 6, in
__bootstrap__
ImportError: libmysqlclient.so.16: cannot open shared object file: No
such file or directory


I can't install python-mysql from aptitude or apt-get as it will
install mysql-common, which will seriously fuck with my mysql install,
as I found out a little earlier  :-)

Ubuntu10

On Mar 1, 10:31 am, vanderkerkoff <ton...@gmail.com> wrote:
> Hi everyone
>
> This is completely driving me crazy :-)
>
> I've installed(reinstalled many times) mysql5.5.9 from source,
> followed this guys instructions
>
> http://greensysadmin.com/2011/01/24/mysql-5-5-installing-from-source-...
>
> Then downloaded and installed django1.2.4 from source
>
> Then downloaded MySQL-Python and installed that, after changing and
> uncommenting this line in site.cfg
>
> mysql_config = /usr/local/mysql/bin/mysql_config
>
> When I try and run a django app, it says
>
> django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb
> module: libmysqlclient.so.16: cannot open shared object file: No such
> file or directory
>
> That file is present in /usr/local/mysql/lib
>
> I've installed, reinstalled, all of the above, and it's still doing
> this, I have no idea why
>
> Can anyone help?  You may have guessed but it's bugging the sh*t out
> of me at the moment :-)
>
> Any help, as always, greatly appreciated.

The libmysqlclient.so file is not installed in a directory which is part of the standard search path for shared libraries on your system.

You will need to either update /etc/ld.so.conf so as to include the directory or when your build the code which is dependent upon it, set the LD_RUN_PATH environment variable to list the directory where the library will be installed.

Go do some reading about ldconfig and LD_RUN_PATH.

You can also set LD_LIBRARY_PATH to list the directory where library installed if just using development server or command line Python, but that isn't the best solution if need to later deploy under Apache as it doesn't use LD_LIBRARY_PATH from your user account.

Graham

vanderkerkoff

unread,
Mar 2, 2011, 10:01:35 AM3/2/11
to Django users
Thanks Graham

I went for the first option and added the path to my mysql libraries
to /etc/ld.so.conf

Never had to do that before though, and I've installed this type of
system many many times. This one is newer ubuntu and newer mysql
though, must be a change in that.

Thanks again

Matt


On Mar 1, 11:35 am, Graham Dumpleton <graham.dumple...@gmail.com>
wrote:

Tom Evans

unread,
Mar 2, 2011, 10:32:12 AM3/2/11
to django...@googlegroups.com
On Wed, Mar 2, 2011 at 3:01 PM, vanderkerkoff <ton...@gmail.com> wrote:
> Thanks Graham
>
> I went for the first option and added the path to my mysql libraries
> to /etc/ld.so.conf
>
> Never had to do that before though, and I've installed this type of
> system many many times.  This one is newer ubuntu and newer mysql
> though, must be a change in that.
>
> Thanks again
>
> Matt
>
>

This has been true for many years; if you install libraries to
locations outside of your OS's LD_LIBRARY_PATH, you're responsible for
ensuring that the linker/rtld has enough information to use it. man
rtld/ld.so/ld

In fact, whilst installing MySQL 5.5 from source, the following
message is emitted (obviously, the location is different):

Libraries have been installed in:
/usr/local/lib/mysql

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,-rpath -Wl,LIBDIR' linker flag

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.


Cheers

Tom

Reply all
Reply to author
Forward
0 new messages