python之bug2_AttributeError: module 'MySQLdb.constants.FIELD_TYPE' has no attribute 'JSON'
1.BUG描述
Django使用MySQL数据库,下载mysqlclient后执行命令python.exe manage.py makemigrations却提示AttributeError: module ‘MySQLdb.constants.FIELD_TYPE’ has no attribute ‘JSON’。
2.前提操作
1.未激活虚拟环境
2.使用File | Settings | Project: movie_v1 | Project Interpreter 下载了mysqlclient
3.在Terminal中已经输入命令python.exe manage.py makemigrations
在第3步时出现上述bug。
3.分析BUG
查看Django文档,发现对mysqlclient的版本有要求,遂猜测可能是版本出了问题。
4.检查版本
猜测正确,卸载旧版本,在Terminal中下载新版本,因为在前提操作中未激活虚拟环境,此处激活一下。
activate django
pip3 install mysqlclient
python.exe manage.py makemigrations
python.exe manage.py migrate
5.成功
6.总结
检查mysqlclient的版本,必须在1.4.0以上,卸载旧版本重新下载。
pip3 install mysqlclient