Python mysqldb: Library not loaded: libmysqlclient.18.dylib
I solved the problem by creating a symbolic link to the library. I.e.
The actual library resides in
/usr/local/mysql/lib
And then I created a symbolic link in
/usr/lib
Using the command:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
so that I have the following mapping:
ls -l libmysqlclient.18.dylib
lrwxr-xr-x 1 root wheel 44 16 Jul 14:01 libmysqlclient.18.dylib -> /usr/local/mysql/lib/libmysqlclient.18.dylib
That was it. After that everything worked fine.
EDIT:
Notice, that since MacOS El Capitan the System Integrity Protection (SIP, also known as "rootless") will prevent you from creating links in /usr/lib/
.
You could disable SIP by following these instructions, but you can create a link in /usr/local/lib/
instead:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/lib/libmysqlclient.18.dylib
Python's MySQLdb can’t find libmysqlclient.dylib with Homebrewed MySQL
This solved my issue on my case:
$ pip uninstall MySQL-python
$ pip install mysqlclient
MySQL-python
turned out to be very old (last commit was 7 years ago). mysqlclient
is the modern version of it, with lots of improvements and bug fixes.
dyld: Library not loaded: libmysqlclient.18.dylib
Solution:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/lib/libmysqlclient.18.dylib
El Capitan upgrade: Library not loaded: /usr/local/lib/libmysqlclient.18.dylib
I was getting the same issue earlier on, I fixed it by reinstalling the gem mysql2
.
Rails on OSX 10.11 El Capitan: Library not loaded: libmysqlclient.18.dylib
The previous answer (pre El Capitan), was to create a symbolic link from mysql's lib directory for the library file into /usr/lib, like this:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
However this now produces 'operation not permitted' due to OS X's integrity controls. This can be worked around by disabling this. However a much easier solution (and one I can verify has worked) is to just symlink it into /usr/local/lib instead:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/lib/libmysqlclient.18.dylib
Good ol' Apple.
Python: MySQLdb and Library not loaded: libmysqlclient.16.dylib
_mysql.so
refers to libmysqlclient.16.dylib
. That is, the shared library that serves as the bridge between Python and the MySQL client library, _mysql.so
, refers to the dynamic library for the MySQL client library, and that library cannot be loaded for some reason.
Questions you need to answer:
- Is there a
libmysqlclient.16.dylib
anywhere on your system? If not, you need to install
the MySQL client software. - If so, is the directory containing that library in your
DYLD_LIBRARY_PATH
setting? If not,
try adding it. - If so, you'll have to ensure that the
libmysqlclient.16.dylib
file is not corrupt. My
copy, installed in/opt/local/lib/mysql5/mysql/libmysqlclient.16.dylib
, courtesy of
MacPorts, has MD5 signaturec79ee91af08057dfc269ee212915801a
and is 1,462,376 bytes in size. What does your copy look like?
rails + MySQL on OSX: Library not loaded: libmysqlclient.18.dylib
The solution is pretty easy; Add the library path in your ~/.bash_profile or ~/.profile file:
MYSQL=/usr/local/mysql/bin
export PATH=$PATH:$MYSQL
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH
If it is still not working (this work for me):
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
There are many blogs with install_name_tool
, which won't work for me because I'm on OSX Lion:
sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/bin/indexer
sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/bin/search
Related Topics
Datetime Dtypes in Pandas Read_Csv
Scraping Dynamic Content Using Python-Scrapy
Dynamically Add Field to a Form
What Does a . in an Import Statement in Python Mean
Scatter Plot and Color Mapping in Python
Python: Importing a Sub‑Package or Sub‑Module
How to Compute the Intersection Point of Two Lines
How to Sort Unicode Strings Alphabetically in Python
Round to 5 (Or Other Number) in Python
Unicodedecodeerror: 'Ascii' Codec Can't Decode Byte 0Xef in Position 1
Pandas - Plotting a Stacked Bar Chart
Python Round Up Integer to Next Hundred
Access Elementtree Node Parent Node
Draw a Transparent Rectangles and Polygons in Pygame
Why Does Assigning to My Global Variables Not Work in Python