0

After downloading MySQLdb from sourceforge here, I ran setup.py to install it. Now when I try to import "MySQLdb" I get the following error:

 >>> import MySQLdb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.9-intel.egg/MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: dlopen(/Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.9-intel.egg/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib
Referenced from: /Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.9-intel.egg/_mysql.so
  Reason: image not found

I'm new to python so I'm not really sure what this means. Can anybody help me figure out how to alleviate this error? Thank you!!!

bruno desthuilliers
  • 75,974
  • 6
  • 88
  • 118
Christopher Shroba
  • 7,006
  • 8
  • 40
  • 68
  • Possibly related http://stackoverflow.com/questions/17703510/dyld-library-not-loaded-reason-image-not-loaded – alko Dec 20 '13 at 09:02
  • It seems that you need to install libmysqlclient18 with your system package manager. On Ubuntu, run ``sudo apt-get install libmysqlclient18`` – Balthazar Rouberol Dec 20 '13 at 09:38

1 Answers1

2

You need the mysql client library to build MySQLdb. The easiest way that I know of to install it in Mac OS X is to get homebrew and then install mysql with:

brew install mysql

Extra bonus - you can easily install python 3 using brew as well.

sjs
  • 8,830
  • 3
  • 19
  • 19