Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install mysqldb on snow leopard

I am trying to get started on working with Python on Django I am by profession a PHP developer and have been told to set up django and python on my current apache and mysql setup however I am having trouble getting the Mysqldb module for python to work, I must of followed about 6 different set of instructions, I am running snow leopard and have mysql installed natively it is not part of MAMP or similar. Please can some tell me where I need to start and what steps I need to follew I would be most grateful.

Thanks

like image 596
Udders Avatar asked Sep 23 '09 13:09

Udders


2 Answers

On MAC OS X 10.6, Install the package as usual. The dynamic import error occurs because of wrong DYLD path. Export the path and open up a python terminal.

$ sudo python setup.py clean

$ sudo python setup.py build

$ sudo python setup.py install

$ export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH

$python

import MySQLdb

Now import MySQLdb should work fine.

You may also want to manually remove the build folder, before build and install. The clean command does not do a proper task of cleaning up the build files.

like image 157
Bharad Avatar answered Sep 17 '22 22:09

Bharad


I'd recomend installing macports (latest svn trunk) and installing mysql from there.

sudo port install mysql5-server

Download the MySQL-python-1.2.2 source

make sure /opt/local/lib/mysql5/bin is in your path or edit site.cfg to include:

mysql_config = /opt/local/lib/mysql5/bin/mysql_config

Comment out line 38 of _mysql.c

// #define uint unsigned int

Then run:

sudo python setup.py install

should be all good.

like image 24
sleepyjames Avatar answered Sep 19 '22 22:09

sleepyjames