import Mysqldb error

Can not import Mysqldb

error Like this:
└─(14:11:27)──> python -c “import MySQLdb” ──(一, 725)─┘
Traceback (most recent call last):
File ““, line 1, in
File “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQLdb/init.py”, line 19, in
import _mysql
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib
Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_mysql.so
Reason: image not found

how to solve it?

add the following stuff to your .bash_profile
mine is .zshrc

1
export DYLD_LIBRARY_PATH=/usr/local/mysql-5.6.27-osx10.8-x86_64/lib:$DYLD_LIBRARY_PATH

“/usr/local/mysql-5.6.27-osx10.8-x86_64/lib “ is my mysql location on OS X,
replace yours, and you will import the mysqldb successfully.

文章目录
  1. 1. Can not import Mysqldb
  2. 2. how to solve it?
,