flask SQLAlchemy 报错ImportError: dlopen(/Users/lmb/flask_hj/lib/python3.7/site-packages/_mysql.cpython-37m-darwin.so, 2): Library not loaded: @rpath/libmysqlclient.21.dylib Referenced from: /Users/lm
关于报错
ImportError: dlopen(/Users/lmb/flask_hj/lib/python3.7/site-packages/_mysql.cpython-37m-darwin.so, 2): Library not loaded: @rpath/libmysqlclient.21.dylib Referenced from: /Users/lmb/flask_hj/lib/python3.7/site-packages/_mysql.cpython-37m-darwin.so Reason: image not found
关于原因
两台电脑.都是python3.7 装的环境什么的都保持一致 我不明白为什么我这点电脑又错那台没有… 问题原因…归纳为未知吧.
解决方案
import pymysql #没有的话, pip3 install pymysql
pymysql.install_as_MySQLdb()