1

Possible Duplicate:
Python import MySQLdb error - Mac 10.6

I have a question that when I was using apache with wsgi to run a django project the system, mysqldb cannot be loaded, and the system report such an error like following:

...
    [Fri Apr 01 11:00:11 2011] [error] [client ::1]   File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/admin/util.py", line 1, in <module>
    [Fri Apr 01 11:00:11 2011] [error] [client ::1]     from django.db import models
    [Fri Apr 01 11:00:11 2011] [error] [client ::1]   File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/__init__.py", line 78, in <module>
    [Fri Apr 01 11:00:11 2011] [error] [client ::1]     connection = connections[DEFAULT_DB_ALIAS]
    [Fri Apr 01 11:00:11 2011] [error] [client ::1]   File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/utils.py", line 93, in __getitem__
    [Fri Apr 01 11:00:11 2011] [error] [client ::1]     backend = load_backend(db['ENGINE'])
    [Fri Apr 01 11:00:11 2011] [error] [client ::1]   File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/utils.py", line 33, in load_backend
    [Fri Apr 01 11:00:11 2011] [error] [client ::1]     return import_module('.base', backend_name)
    [Fri Apr 01 11:00:11 2011] [error] [client ::1]   File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    [Fri Apr 01 11:00:11 2011] [error] [client ::1]     __import__(name)
    [Fri Apr 01 11:00:11 2011] [error] [client ::1]   File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/gis/db/backends/mysql/base.py", line 1, in <module>
    [Fri Apr 01 11:00:11 2011] [error] [client ::1]     from django.db.backends.mysql.base import *
    [Fri Apr 01 11:00:11 2011] [error] [client ::1]   File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 14, in <module>
    [Fri Apr 01 11:00:11 2011] [error] [client ::1]     raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
    [Fri Apr 01 11:00:11 2011] [error] [client ::1] TemplateSyntaxError: Caught ImproperlyConfigured while rendering: Error loading MySQLdb module: dlopen(/Users/LechterLin/.python-eggs/MySQL_python-1.2.3-p
    y2.7-macosx-10.6-intel.egg-tmp/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib
    [Fri Apr 01 11:00:11 2011] [error] [client ::1]   Referenced from: /Users/LechterLin/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp/_mysql.so
    [Fri Apr 01 11:00:11 2011] [error] [client ::1]   Reason: image not found

the wsgi file in django project and httpd.conf in apache are correct, cause I use the same file(or command) in WindowsXP the project can run successfully.

This report is similar with the error I only install python and MySQL without MySQL-python adapter. So do these two error have some relationship?

I searched this error through google, seems this problem can be only found in MACOSX10.6. My system issues are like following: Os: MACOSX10.6.7 snow leopard MySQL: 5.5.10 python: 2.7 MySQL-python adapter: 1.2.3 Apache: 2.2.17 mod_wsgi: 3.3 django: 1.3

Hope to get your help! Thanks very much!

Community
  • 1
  • 1
  • Another duplicate of http://stackoverflow.com/questions/4730787/python-import-mysqldb-error-mac-10-6 – dting Apr 01 '11 at 06:35

1 Answers1

1

Go read:

https://groups.google.com/d/topic/modwsgi/aNSeRUiF1OY/discussion

Go through the checks there, adjusting as necessary based on where you have things installed.

Then follow up to that discussion on mod_wsgi mailing list with what results you get so can be debugged further. StackOverflow does not work as a very good place to try and debug issues, only useful if someone knows the exact answer already. Unfortunately the last person with the problem could not be bothered to respond to the questions or indicate how they solved the problem so don't have a definitive short answer as yet.

Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134