django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3
2019-05-14 22:34
936 查看
报错环境 python=3.6,django=2.2,PyMySQL=0.9.3
……
django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.
解决方法:
Django连接MySQL时默认使用MySQLdb驱动,但MySQLdb不支持Python3,因此这里将MySQL驱动设置为pymysql,使用 pip install pymysql 进行安装,然后在工程文件__init__.py添加以下代码即可。
第一种:
django降到2.1.4版本就OK了
第二种(仍使用django 2.2版本):
#找到Python环境下 django包,并进入到backends下的mysql文件夹
#找到base.py文件,注释掉 base.py 中如下部分(35/36行)
if version < (1, 3, 3): raise ImproperlyConfigured("mysqlclient 1.3.3 or newer is required; you have %s" % Database.__version__)
此时仍会会报错,报错信息如下:
AttributeError: ‘str’ object has no attribute ‘decode’
#找到operations.py文件(46行),将decode改为encode
#linux vim 查找快捷键:?decode
if query is not None: query = query.decode(errors='replace') return query
#改为
if query is not None: query = query.encode(errors='replace') return query
相关文章推荐
- django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.
- django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.3 or newer is required; you have 0.7.11
- Django连接mysql django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.3 or newer is required;
- macOS使用django安装mysqlclient遇到的问题(mysqlclient 1.3.3 or newer is required)
- 解决 Django 的 if version (1, 3, 3): raise ImproperlyConfigured("mysqlclient 1.3.3 or newer is requi
- Hue 安装问题django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: libmysqlclient.so
- SpringMVC:com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax;
- 解决mysql 添加插件时提示 ERROR 1289 (HY000): The &#8216;plugin&#8217; feature is disabled; you need MySQL built with &#8216;HAVE_DLOPEN&#
- Cannot connect to WMI provider.You do not have permission or the server is unreachable.Note that you can only manager SQL Server 2005 and later version with SQL Server Configuration Manager.Invalid namespace [0x8004100e]
- com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax;
- 误用关键字-_mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax;
- XAMPP里tomcat启动报错:Make sure you have Java JDK or JRE installed and the required ports are free
- 【Django】WIN10安装MySQL-python时遇到403 SSL is required
- 安装Visual Studio 2010时提示"The location specified for the help content store is invalid or you do not have access to it".
- SQL Server 2008R2安装错误—“is not a valid login or you do have permission”
- Error:MySQLdb Module 'Did you install mysqlclient or MySQL-python?
- 解决The'InnoDB'feature is disabled;you need MySQL built with 'InnoDB' to have it的问题
- Can't find msguniq. Make sure you have GNU gettext tools 0.15 or newer installed.
- django.core.exceptions.ImproperlyConfigured: No DjangoTemplates backend is configured.
- 解决The 'InnoDB' feature is disabled; you need MySQL built with 'InnoDB' to have it (http://ruijunsu)