Referenced from: /Library/Python/2.7/site-packages/_mysql.so
Reason: image not found
這個原本發生在我移掉舊版的 mariadb v10.1 改安裝 mariadb v10.2 或切換 mariadb 為 mysql 時會發生。
網路上解法:
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
我下了上面的指令,還是無效。
使用 brew unlink mysql 再 brewlink mysql 還是無效。
仔細去看上面的 path 發現我電腦裡的實際path 不是那個,所以改成使用:
sudo ln -s /usr/local/Cellar/mysql/5.7.18_1/lib/libmysqlclient.dylib /usr/local/lib/libmysqlclient.18.dylib
然後顯示
ln: /usr/local/lib/libmysqlclient.18.dylib: File exists
所以,把 link 檔案刪掉後,再下一次,結果還是不行。原來是之前 mariadb 的 path 不是在
/usr/local/lib/libmysqlclient.18.dylib
而是在 /usr/local/opt/mariadb/lib/libmysqlclient.18.dylib
所以,先
rm /usr/local/opt/mariadb/lib/libmysqlclient.18.dylib
再
makedir -p /usr/local/opt/mariadb/lib/
sudo ln -s /usr/local/Cellar/mysql/5.7.18_1/lib/libmysqlclient.dylib /usr/local/opt/mariadb/lib/libmysqlclient.18.dylib
大功告成,收工。