title: Error loading MySQLdb module in MACOSX10.6 (Apache & mod_wsgi)
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4730787/python-import-mysqldb-error-mac-10-6">Python import MySQLdb error - Mac 10.6</a>  </p>
  </blockquote>
  
  
  
  <p>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:</p>
  
  <pre><code>...
      [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 &lt;module&gt;
      [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 &lt;module&gt;
      [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 &lt;module&gt;
      [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 &lt;module&gt;
      [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
  </code></pre>
  
  <p>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.</p>
  
  <p>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?</p>
  
  <p>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</p>
  
  <p>Hope to get your help! Thanks very much!</p>