I am trying to use MySQLdb
library.
I have install the library using pip install mysqlclient
When running: import MySQLdb as db
I have the following error:
import MySQLdb as db
File "/Users/Solal/anaconda3/lib/python3.7/site-packages/MySQLdb/__init__.py", line 19, in <module>
from . import _mysql
ImportError: dlopen(/Users/Solal/anaconda3/lib/python3.7/site-packages/MySQLdb/_mysql.cpython-37m-darwin.so, 2): Library not loaded: /usr/local/opt/mysql/lib/libmysqlclient.21.dylib
Referenced from: /Users/Solal/anaconda3/lib/python3.7/site-packages/MySQLdb/_mysql.cpython-37m-darwin.so
Reason: image not found
That's all the files I have in my MySQLdb
repo:
constants
__pycache__
converters.py
_exceptions.py
cursors.py
_mysql.cpython-37m-darwin.so
release.py
compat.py
times.py
connections.py
Also I have no folder mysql
in /usr/local/opt
I have found online a fix as follow: sudo ln -s /usr/local/Cellar/mysql/5.7.10/lib/libmysqlclient.dylib /usr/local/lib/libmysqlclient.18.dylib
However I have nothing in my /usr/local/Cellar/
folder
我仅通过运行就成功使其工作:
brew install mysql
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.