After upgrading to the latest version of Mac OS X Python mysqldb cannot find the libmysqlclient.18.dylib problem, try the following solution:
1. Upgrade to update MySQL to the latest version, invalid;
2. Upgrade Python mysqldb to the latest version, invalid;
3. Re-linking Libmysqlclient.18.dylib to/usr/local/mysql/lib/libmysqlclient.20.dylib is still invalid;
Find a solution on StackOverflow and the final problem is resolved as follows:
Http://stackoverflow.com/questions/6383310/python-mysqldb-library-not-loaded-libmysqlclient-18-dylib
My preferred method is-actually fix the library rather than playing with environment variables Ally be in scope depending on how the application is run. This was actually a fairly simple process.
First, look at the "error output to" where the offending Python module is located:
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
Okay, so the offending file is/library/python/2.7/site-packages/_mysql.so
Next, figure out where _mysql.so thinks it should find Libmysqlclient.18.dylib:
%Otool-L/Library/Python/2.7/Site-Packages/_mysql.So/Library/Python/2.7/Site-Packages/_mysql.So:Libmysqlclient.18.dylib (compatibility version 18.0 0, current version 18.0 . 0) /usr /lib/libsystem.b. (compatibility version 1.0.0, current version 169.3.< Span class= "lit" >0)
So, it's looking for libmysqlclient.18.dylib with no path information, let's fix that:
% sudo install_name_tool -change Libmysqlclient. 18.dylib /usr/local< Span class= "pun" >/mysql/lib/ libmysqlclient. 18.dylib /library/ Python/2.7/site-< Span class= "PLN" >packages/_mysql. So
Now _mysql.so knows the full path to the library and everything works, regardless of environment variables.
%Otool-L/Library/Python/2.7/Site-Packages/_mysql.So/Library/Python/2.7/Site-Packages/_mysql.So: /Usr/Local/Mysql/Lib/Libmysqlclient.18.dylib (compatibility version 18.0 0, current version 18.0 . 0) /usr /lib/libsystem.b. (compatibility version 1.0.0, current version 169.3.< Span class= "lit" >0)
Python 2.7.10 libmysqlclient.18.dylib solution not found