Python3.6报错:ModuleNotFoundError: No module named 'MySQLdb'

from sqlalchemy import create_engine

engine = create_engine('mysql://root:[email protected]:3306/test?charset=utf8')

报错:

ModuleNotFoundError: No module named 'MySQLdb'

解决方法:

MySQLdb只支持Python2.,还不支持3.
可以用PyMySQL代替。安装方法:

pip install PyMySQL

再添加

from sqlalchemy import create_engine

import pymysql
pymysql.install_as_MySQLdb()

参考
python3.6报错ModuleNotFoundError: No module named 'MySQLdb’及解决方法

你可能感兴趣的:(python)