最近我一直在研究烧瓶。导入MySQL时出现错误。
from flask_mysqldb import MySQL
昨天我花了大部分时间,尝试从堆栈溢出尝试不同的解决方案以使其正常运行,但没有任何效果,所以我要发布一个新问题。
from flask_mysqldb import MySQL
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/abhishek/Library/Python/2.7/lib/python/site-packages/flask_mysqldb/__init__.py", line 1, in <module>
import MySQLdb
File "/Users/abhishek/Library/Python/2.7/lib/python/site-packages/MySQLdb/__init__.py", line 18, in <module>
import _mysql
ImportError: dlopen(/Users/abhishek/Library/Python/2.7/lib/python/site-packages/_mysql.so, 2): Library not loaded: @rpath/libmysqlclient.21.dylib
Referenced from: /Users/abhishek/Library/Python/2.7/lib/python/site-packages/_mysql.so
Reason: image not found
我正在使用MacOS Mojave。
已安装的烧瓶
pip install flask
已安装flask-mysqldb
pip install flask-mysqldb