First time using mysql…ImportError:


I have looked all over and tried everything to resolve this issue for a day or two, but haven’t had any luck.

I am using flask and sql for the first time(macOS), I have everything installed. But I am guessing that it is either installed incorrectly, or in the wrong folder.

I installed sql directly from their website, I then followed this advice here…

$ open -t .bash_profile

export PATH=${PATH}:/usr/local/mysql/bin/
I know that it does work because I am able to go into the database in my terminal. my Flask app does work (it runs before adding all of the sql code), but the only thing I am having trouble with is running my program after importing(from flask_mysqldb import MySQL).

This is the tutorial I am following as well,

my error is here…

Error: While importing “app”, an ImportError was raised:

Traceback (most recent call last):
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask/”, line 235, in locate_app
File “/Users/jonathanmast/flask_prac/”, line 2, in
from flask_mysqldb import MySQL
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask_mysqldb/”, line 1, in
import MySQLdb
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/MySQLdb/”, line 18, in
from . import _mysql
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/MySQLdb/, 2): Library not loaded: @rpath/libmysqlclient.18.dylib
Referenced from: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/MySQLdb/