简体   繁体   中英

ImportError: No module named flask_mysqldb ("from flask_mysqldb import MySQL")

I'm using python 3.10. I want to use MySQL database, but whenever I am trying to import the module it throws the error. I am using MAC OS. There are certain file for windows to import but I wasn't able to find solution for Mac OS.

ImportError: No module named flask_mysqldb

from flask_mysqldb import MySQL

do you have flask_mysqldb installed on your work environment? if not

  • Create a virtual environment for your script using the command

  • pip3 install virtualenv

  • virtualenv "desired name for virtual environment"

  1. install flask_mysqldb according to the documentation
  • pip install flask-mysqldb.

  • from flask import Flask

  • from flask_mysqldb import MySQL

Reference: https://flask-mysqldb.readthedocs.io/en/latest/

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