Graham,

This is what I got.

>$ file ./lib/python2.7/site-packages/_mysql.so
./lib/python2.7/site-packages/_mysql.so: Mach-O 64-bit bundle x86_64

>$ otool -L ./lib/python2.7/site-packages/_mysql.so
./lib/python2.7/site-packages/_mysql.so:
libmysqlclient.18.dylib (compatibility version 18.0.0, current version
18.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version
125.2.0)

So, it seems _mysql.so is already for x86_64 architecture. But there is a
inconsistency about libSystem.B.dylib according the versions reported by
otool. But I am not sure if that dylib is ever used by MySQLdb or not.

Any thoughts?

Jim

On Tue, Aug 23, 2011 at 6:41 PM, Graham Dumpleton <
[email protected]> wrote:

> What do you get if you run 'file' on _mysql.so extension module file in
> Python installation? Also run 'otool -L _mysql.so' as well to see what
> library it is finding. You have 64 bit libraries so should be okay unless
> you have 32 bit somewhere else and it is finding that instead.
>
> Graham
>
>
> On Wednesday, 24 August 2011, Jianbao Tao <[email protected]> wrote:
> > Thank you so much, Graham. You may have pointed me to the right
> direction.
> > So, the following is what I get, where I basically filed all
> libmysqlclient* files under /usr/local/mysql/lib/. It seems the mysql I
> installed is for i386 architecture, but all the libmysqlclient files seem
> for x86_64, which is really confusing. Anyway, do you have any ideas of
> what's happening here?
> >>$ mysql --version
> > mysql  Ver 14.14 Distrib 5.5.14, for osx10.6 (i386) using readline 5.1
> >>$ ls /usr/local/mysql/lib/libmysqlclient*
> > /usr/local/mysql/lib/libmysqlclient.18.dylib
> /usr/local/mysql/lib/libmysqlclient_r.18.dylib
> > /usr/local/mysql/lib/libmysqlclient.a
>  /usr/local/mysql/lib/libmysqlclient_r.a
> > /usr/local/mysql/lib/libmysqlclient.dylib
>  /usr/local/mysql/lib/libmysqlclient_r.dylib
> >>$ file /usr/local/mysql/lib/libmysqlclient.18.dylib
> > /usr/local/mysql/lib/libmysqlclient.18.dylib: Mach-O 64-bit dynamically
> linked shared library x86_64
> >>$ file /usr/local/mysql/lib/libmysqlclient.dylib
> > /usr/local/mysql/lib/libmysqlclient.dylib: Mach-O 64-bit dynamically
> linked shared library x86_64
> >>$ file /usr/local/mysql/lib/libmysqlclient.a
> > /usr/local/mysql/lib/libmysqlclient.a: current ar archive random library
> >>$ file /usr/local/mysql/lib/libmysqlclient_r.18.dylib
> > /usr/local/mysql/lib/libmysqlclient_r.18.dylib: Mach-O 64-bit dynamically
> linked shared library x86_64
> >>$ file /usr/local/mysql/lib/libmysqlclient_r.dylib
> > /usr/local/mysql/lib/libmysqlclient_r.dylib: Mach-O 64-bit dynamically
> linked shared library x86_64
> >>$ file /usr/local/mysql/lib/libmysqlclient_r.a
> > /usr/local/mysql/lib/libmysqlclient_r.a: current ar archive random
> library
> >
> >
> > On Tue, Aug 23, 2011 at 5:09 PM, Graham Dumpleton <
> [email protected]> wrote:
> >
> > On 24 August 2011 08:58, Jim <[email protected]> wrote:
> >> Hello folks,
> >> This probably has been discussed many times, but I still can't find any
> >> solution yet. Basically, it turns out that python can load MySQLdb just
> >> fine, but Apache can't load MySQLdb from the wsgi script.
> >> Here is the configuration of my machine.
> >> Mac OS X Snow Leopard 10.6.8
> >> Apache2 (shipped with Snow Leopard)
> >
> > Which is fat and by default will run as 64 bit.
> >
> >> Python 2.7 (from python.org)
> >
> > Which I believe now comes as fat binary so should be okay.
> >
> >> virtualenv
> >> MySQL-python 1.2.3
> >
> > This is where problems start.
> >
> > Because Apache is going to run as 64 bit, and because MySQL client
> > libraries are not fat but for a specific architecture, you need to
> > ensure you installed 64 bit MySQL and not 32 but version.
> >
> > For example, on my system I have:
> >
> >  mysql-5.1.53-osx10.6-x86_64
> >
> > and get:
> >
> >  $ file /usr/local/mysql/lib/libmysqlclient.16.dylib
> >  /usr/local/mysql/lib/libmysqlclient.16.dylib: Mach-O 64-bit
> > dynamically linked shared library x86_64
> >
> > I suspect you will find that yours is only 32 bit and not 64 bit. That
> > is why you would get error:
> >
> >  Reason: image not found
> >
> > Can you run the 'file' command on the dylib and see what it says.
> >
> > Graham
> >
> >> BTW, I can import MySQLdb with no problem under python interpreter.
> >> I am using python2.7 in a virtual environment created by virtualenv.
> Here is
> >> the error info extracted from the Apache error log. To make the lines
> >> shorter, I deleted all the time tags in the brackets.
> >> Any ideas how to fix it?
> >> [] mod_wsgi (pid=3136): Target WSGI script
> >> '/Users/jianbao/projects/tao.com/mysite/apache/django.wsgi' cannot be
> loaded
> >> as Python module.
> >> [] mod_wsgi (pid=3136): Exception occurred processing WSGI script
> >> '/Users/jianbao/projects/tao.com/mysite/apache/django.wsgi'.
> >> [] Traceback (most recent call last):
> >> []   File "/Users/jianbao/projects/tao.com/mysite/apache/django.wsgi",
> line
> >> 56, in <module>
> >> []     import MySQLdb
> >> []   File
> >> "/Users/jianbao/projects/
> tao.com/mysite/lib/python2.7/site-packages/MySQLdb/__init__.py",
> >> line 19, in <module>
> >> []     import _mysql
> >> [] ImportError:
> >> dlopen(/Users/jianbao/projects/
> tao.com/mysite/lib/python2.7/site-packages/_mysql.so,
> >> 2): Library not loaded: libmysqlclient.18.dylib
> >> []   Referenced from:
> >> /Users/jianbao/projects/
> tao.com/mysite/lib/python2.7/site-packages/_mysql.so
> >> []   Reason: image not found
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "modwsgi" group.
> >> To view this discussion on the web visit
> >> https://groups.google.com/d/msg/modwsgi/-/_S2GuYUGqosJ.
> >> To post to this group, send email to [email protected].
> >> To unsubscribe from this group, send email to
> >> [email protected].
> >> For more options, visit this group at
> >> http://groups.google.com/group/modwsgi?hl=en.
> >>
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "modwsgi" group.
> > To post to this group, send email to
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "modwsgi" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> [email protected] <
> modwsgi%[email protected]>.
>
> > For more options, visit this group at
> http://groups.google.com/group/modwsgi?hl=en.
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "modwsgi" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/modwsgi?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/modwsgi?hl=en.

Reply via email to