Mac OS 10.14上的Python MySQL导入错误

时间:2018-11-22 05:58:15

标签: python mysql flask macos-mojave flask-mysql

我是python的新手,我似乎找不到解决此错误的方法。尝试导入Mysql Flask扩展名时出现此错误:

>>> import flask_mysqldb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask_mysqldb/__init__.py", line 1, in <module>
    import MySQLdb
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/MySQLdb/__init__.py", line 18, in <module>
    import _mysql
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/_mysql.cpython-37m-darwin.so, 2): Library not loaded: @rpath/libmysqlclient.21.dylib
  Referenced from: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/_mysql.cpython-37m-darwin.so
  Reason: image not found

在尝试执行flask应用程序时,我首先遇到此错误,但是即使尝试从命令行导入模块,也会遇到相同的错误。

我的设置是:

  • python 3.7.1
  • MySQL Community Server 8.0.13
  • MacOS 10.14 Mojave

我试图实施针对类似问题here的解决方案,但无法使其正常工作。

0 个答案:

没有答案