Skip to content

Instantly share code, notes, and snippets.

@julian-garrido
Created June 10, 2014 11:40
Show Gist options
  • Save julian-garrido/43093201555a7cfd55b0 to your computer and use it in GitHub Desktop.
Save julian-garrido/43093201555a7cfd55b0 to your computer and use it in GitHub Desktop.
MySQLdb installation and bug solving
All the steps are needed because of library dependencies:
1.- Download and Install mysql from: http://www.mysql.com/downloads/mysql/
2.- install mysql-python
a) If you install it using pip install mysql-python: it will be installed at /Library/Python/2.6/site-packages/...
b) If you install it downloading the src and building it, it is installed at /LibraryFrameworks/Python.framework/Version/2.7/lib/python2.7/site-packages
i) This is the option that worked for me because the system had 2.6 but I was using python 2.7.
ii) Download the code from http://sourceforge.net/projects/mysql-python/?source=dlp
iii) python setup.py build
iv) sudo python setup.py install
check installation:
$ python
>>> import MySQLdb
The next error may occur:
import _mysql
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.6-intel.egg/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib
Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.6-intel.egg/_mysql.so
Reason: image not found
solution: sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/lib
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment