This is an issue with how MySQLdb Python module is built. Can you tell
me how you installed it?

Did you use pip, or did you download package as tar.gz and run setup.py in it?

I have tried twice before to sort this out with people on IRC but they
would not do what I asked them to help me solve it properly. I am at
least most of the way along sorting out what the issue is however. :-)

Graham

On 19 November 2011 08:41, mathew davis <[email protected]> wrote:
> I am trying to run django on osx 10.7 (lion) with apache mod_wsgi and
> virtualenv.
> My site works if I use the django testing server:
>
>>     (baseline)otter:hello mathew$ python manage.py runserver
>
> but it doesn't work when I run apache. The core of the error seems to be
>
>>     Library not loaded: libmysqlclient.16.dylib
>
> I think its to do with the path apache is using to locate
> libmysqlclient.16.dylib
>
> when I run otool in the lib directory it looks good
>
>>     otter:lib mathew$ pwd
>>         /usr/local/mysql/lib
>>
>>     otter:lib mathew$ otool -L libmysqlclient.16.dylib
>>         libmysqlclient.16.dylib:
>>             libmysqlclient.16.dylib (compatibility version 16.0.0, current
>> version 16.0.0)
>>             /usr/lib/libSystem.B.dylib (compatibility version 1.0.0,
>> current version 125.0.1)
>>
>
> but from outside it can't find it
>
>>     otter:lib mathew$ cd /
>>     otter:/ mathew$ otool -L libmysqlclient.16.dylib
>>     otool: can't open file: libmysqlclient.16.dylib (No such file or
>> directory)
>
> if i manually set DYLD_LIBRARY_PATH otool works
>
>> otter:lib mathew$ DYLD_LIBRARY_PATH=/usr/local/mysql/lib otter:lib
>> mathew$ otool -L libmysqlclient.16.dylib libmysqlclient.16.dylib:
>>     libmysqlclient.16.dylib (compatibility version 16.0.0, current
>> version 16.0.0)     /usr/lib/libSystem.B.dylib (compatibility version
>> 1.0.0, current version 125.0.1)
>
> When I run the django testing server, my .bash_profile sets up the
> virtualenv and the path to the mysql dynamic library
>
>>     export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/:$DYLD_LIBRARY_PATH
>>     export PATH
>
> When i run apache it finds my virtualenv paths, but it doesn't seem to find
> the dynamic library path.
>
> I tried adding this path to /usr/sbin/envvars
>
>>     DYLD_LIBRARY_PATH="/usr/lib:/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"
>>     export DYLD_LIBRARY_PATH
>
> and to /private/etc/paths.d/libmysql
>
>>     /usr/local/mysql/lib
>
> then restarted the machine
> but that has not changed the error message.
>
>>     Error loading MySQLdb module:
>> dlopen(/usr/local/python_virtualenv/baseline/lib/python2.7/site-packages/_mysql.so,
>> 2):
>>         Library not loaded: libmysqlclient.16.dylib
>
>
> I don't think is a permissions issue:
>
>>     -rwxr-xr-x  1 root  wheel  3787328  4 Dec  2010
>> libmysqlclient.16.dylib
>>
>>     drwxr-xr-x  39 root    wheel   1394 18 Nov 21:07 /
>>     drwxr-xr-x@ 15 root    wheel    510 24 Oct 22:10 /usr
>>     drwxrwxr-x  20 root    admin    680  2 Nov 20:22 /usr/local
>>     drwxr-xr-x  20 mathew  admin    680  9 Nov 21:58
>> /usr/local/python_virtualenv
>>     drwxr-xr-x   6 mathew  admin    204  2 Nov 21:36
>> /usr/local/python_virtualenv/baseline
>>     drwxr-xr-x   4 mathew  admin    136  2 Nov 21:26
>> /usr/local/python_virtualenv/baseline/lib
>>     drwxr-xr-x  52 mathew  admin   1768  2 Nov 21:26
>> /usr/local/python_virtualenv/baseline/lib/python2.7
>>     drwxr-xr-x  18 mathew  admin    612  4 Nov 21:20
>> /usr/local/python_virtualenv/baseline/lib/python2.7/site-packages
>>     -rwxr-xr-x   1 mathew  admin  66076  2 Nov 21:18
>> /usr/local/python_virtualenv/baseline/lib/python2.7/site-packages/_mysql.so
>
>
>
> **What do i need to do so that mod_wsgi will find libmysqlclient.16.dylib?**
>
>
> apache and mysql are both 64 bit:
>
>> otter:lib mathew$ file /usr/sbin/httpd /usr/sbin/httpd: Mach-O
>> universal binary with 2 architectures /usr/sbin/httpd (for
>> architecture x86_64):    Mach-O 64-bit executable x86_64 /usr/sbin/httpd
>> (for architecture i386):    Mach-O executable i386 otter:lib mathew$
>>
>> otter:lib mathew$ 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
>
>
> here's some more detail of the error:
>
>
>> Request URL:    http://hello.local/ Django Version:    1.3.1 Exception
>> Type:    ImproperlyConfigured Exception Value:     Error loading MySQLdb
>> module:
>>
>> dlopen(/usr/local/python_virtualenv/baseline/lib/python2.7/site-packages/_mysql.so,
>> 2): Library not loaded: libmysqlclient.16.dylib   Referenced from:
>>
>> /usr/local/python_virtualenv/baseline/lib/python2.7/site-packages/_mysql.so
>> Reason: image not found Exception
>> Location:
>> /usr/local/python_virtualenv/baseline/lib/python2.7/site-packages/django/db/backends/mysql/base.py
>> in <module>, line 14 Python Executable:    /usr/sbin/httpd Python
>> Version:    2.7.2 Python Path:
>>
>> ['/usr/local/python_virtualenv/baseline/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg',
>>
>> '/usr/local/python_virtualenv/baseline/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg',
>> '/usr/local/python_virtualenv/baseline/lib/python27.zip',
>> '/usr/local/python_virtualenv/baseline/lib/python2.7',
>> '/usr/local/python_virtualenv/baseline/lib/python2.7/plat-darwin',
>> '/usr/local/python_virtualenv/baseline/lib/python2.7/plat-mac',
>>
>> '/usr/local/python_virtualenv/baseline/lib/python2.7/plat-mac/lib-scriptpackages',
>> '/usr/local/python_virtualenv/baseline/lib/python2.7/lib-tk',
>> '/usr/local/python_virtualenv/baseline/lib/python2.7/lib-old',
>> '/usr/local/python_virtualenv/baseline/lib/python2.7/lib-dynload',
>> '/usr/local/Cellar/python/2.7.2/lib/python2.7',
>> '/usr/local/Cellar/python/2.7.2/lib/python2.7/plat-darwin',
>> '/usr/local/Cellar/python/2.7.2/lib/python2.7/lib-tk',
>> '/usr/local/Cellar/python/2.7.2/lib/python2.7/plat-mac',
>>
>> '/usr/local/Cellar/python/2.7.2/lib/python2.7/plat-mac/lib-scriptpackages',
>> '/usr/local/python_virtualenv/baseline/lib/python2.7/site-packages',
>> '/usr/local/python_virtualenv/baseline/lib/python2.7/site-packages/PIL',
>> '/Users/mathew/dev',  '/usr/local/mysql/lib/']
>
>
> --
> 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/-/YIrdgT4hh-oJ.
> 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