简体   繁体   中英

in Flask MySQL and SqlAlchemy command db.create_all() give error

ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/MySQLdb/_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/MySQLdb/_mysql.cpython-37m-darwin.so
  Reason: image not found

After entering from app import db and db.create_all() in terminal above error comes

Step 1: Create virtual environment Step 2: Install all necessary module eg Flask, SQLAlchemy, however, you won't be able to install MySQLDB so instead of that use pip install pymysql Step 3: app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:Vrishab2145@localhost/testOne' In step 3, must add mysql+pymysql

Hureyy..... It worked for me Important is creating virtual environment. You don't need to go through nasty SSL and other things

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM