django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlc...

版权声明:https://blog.csdn.net/San_South https://blog.csdn.net/San_South/article/details/80960253

使用Django2.0进行开发是出现如上错误,具体如下:

Traceback (most recent call last):
  ...
    import MySQLdb as Database
ModuleNotFoundError: No module named 'MySQLdb'

The above exception was the direct cause of the following exception:
...
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
Did you install mysqlclient?

解决方案:
init.py文件里添加两行代码:

import pymysql

pymysql.install_as_MySQLdb()

猜你喜欢

转载自blog.csdn.net/San_South/article/details/80960253
今日推荐