搭建Django2.0+Python3+MySQL5时同步数据库时报错:
raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)
django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.
原因:由于 mysqlclient 目前不支持高版本python,出现这个错误之后可以根据错误提示找到文件位置,打开 base.py 文件,找到以下代码并注释掉:
version = Database.version_info if version < (1, 3, 13): raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)
AttributeError: 'str' object has no attribute 'decode'
原因:python3.5和Python2.7在套接字返回值解码上的区别
python在bytes和str两种类型转换,所需要的函数依次是encode(),decode()
解决:把decode改为encode即可