0

I am using python 2.7 and MySQLdb, while doing import MySQLdb its throwing below error -

import MySQLdb
  File "/Library/Python/2.7/site-packages/MySQLdb/__init__.py", line 19, in <module>
    import _mysql
ImportError: dlopen(/Library/Python/2.7/site-packages/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib
  Referenced from: /Library/Python/2.7/site-packages/_mysql.so
  Reason: image not found
1

1 Answer 1

1

You need to have the mysql client installed on your system.

If you have, then you have the file libmysqlclient.18.dylib located somewhere on your system. Make sure the path where it is located is included in your DYLD_LIBRARY_PATH environment variable.

Sign up to request clarification or add additional context in comments.

7 Comments

i do have client installed and path is included for environment variable more ~/.bash_profile DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/mysql/lib/ PATH=$PATH:/usr/local/mysql/bin:/Users/Jaimin/Development/Django-1.3.1/django/bin/
Is the file libmysqlclient.18.dylib in the folder /usr/local/mysql/lib/? If not, is a different version located there?
file is there, here is the list of file in there >libmysqlclient.18.dylib libmysqlclient_r.18.dylib libmysqld-debug.a plugin libmysqlclient.a libmysqlclient_r.a libmysqld.a libmysqlclient.dylib libmysqlclient_r.dylib libmysqlservices.a
Unless you are starting python from a bash shell (not the terminal app) you need to set the environment variables in your environment.plist. Editing .bash_profile affects only bash shells (and only if you restarted your mac)
:) I am starting from terminal app and have restarted mac right after install and setting up bash_profile...tried to read the variable on terminal it doesn't recognize though it recognize PATH from it..so really not sure whats going on.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.