Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /home/adam/sites/adamyoung.net/index.php:2) in drupal_send_headers() (line 1043 of /home/adam/sites/adamyoung.net/includes/bootstrap.inc).
  • Warning: Cannot modify header information - headers already sent by (output started at /home/adam/sites/adamyoung.net/index.php:2) in drupal_send_headers() (line 1043 of /home/adam/sites/adamyoung.net/includes/bootstrap.inc).
  • Warning: Cannot modify header information - headers already sent by (output started at /home/adam/sites/adamyoung.net/index.php:2) in drupal_send_headers() (line 1043 of /home/adam/sites/adamyoung.net/includes/bootstrap.inc).
  • Warning: Cannot modify header information - headers already sent by (output started at /home/adam/sites/adamyoung.net/index.php:2) in drupal_send_headers() (line 1043 of /home/adam/sites/adamyoung.net/includes/bootstrap.inc).
  • Warning: Cannot modify header information - headers already sent by (output started at /home/adam/sites/adamyoung.net/index.php:2) in drupal_send_headers() (line 1043 of /home/adam/sites/adamyoung.net/includes/bootstrap.inc).

MySQL-python on OS X

First off, I'm no pro at python. PHP is (currently) my area of expertise when it comes to scripting languages. That said, I'm intrigued by Django and wanted to try it out for a couple of small internal projects that have been sitting at the bottom of my todo list. I went to work building a development environment on my macbook pro and ran into the following error while trying to get MySQL-python working. This error occurred after installing MySQL-python and trying to load the library with the interpreter via the CLI. I've bolded the part I found interesting.

>>> import MySQLdb
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/MySQL_python-1.2.2-py2.4-macosx-10.3-fat.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/MySQL_python-1.2.2-py2.4-macosx-10.3-fat.egg/_mysql.pyc, but /Users/adam/Desktop/MySQL-python-1.2.2 is being added to sys.path
Traceback (most recent call last):
File "", line 1, in ?
File "MySQLdb/__init__.py", line 19, in ?
import _mysql
File "build/bdist.macosx-10.3-fat/egg/_mysql.py", line 7, in ?
File "build/bdist.macosx-10.3-fat/egg/_mysql.py", line 6, in __bootstrap__
ImportError: Failure linking new module: /Users/adam/.python-eggs/MySQL_python-1.2.2-py2.4-macosx-10.3-fat.egg-tmp/_mysql.so: Library not loaded: /usr/local/mysql/lib/mysql/libmysqlclient_r.15.dylib
Referenced from: /Users/adam/.python-eggs/MySQL_python-1.2.2-py2.4-macosx-10.3-fat.egg-tmp/_mysql.so
Reason: image not found
>>>

I spent maybe 5 minutes searching Google but nobody had a simple answer that I liked. I didn't want to re-compile python or download somebody's pre-built libraries. I'm trying to test out Django with as little time and changes to my machine as possible.

Not being a python regular, I don't know what most of the error above means. But, I do know that the bolded file doesn't exist on my computer. Having a look, I found the file in a similar yet more reasonable area: /usr/local/mysql/lib/libmysqlclient_r.15.dylib

Here's the simple fix:
sudo mkdir /usr/local/mysql/lib/mysql/
sudo ln -s /usr/local/mysql/lib/libmysqlclient_r.15.dylib /usr/local/mysql/lib/mysql/

A quick python manage.py syncdb on my Django project proved success.

Comments

Had this exact problem, and your solution worked perfectly. Thanks!

thanks so much

rather than just link in a single file, add a link that "fixes" the problem of the extra directory level.

sudo ln -s . /usr/local/mysql/lib/mysql

now /usr/local/mysql/lib/mysql points to /usr/local/mysql/lib, and any file in that directory is visible.

Right, this is something I ended up doing when trying to get PHP to compile with mysql support on OS X 10.5. Thanks for mentioning it.

Thanks, worked like a charm when I linked the entire directory.

Thank you so much for this fix. Saved me HOURS.