zoukankan      html  css  js  c++  java
  • django2.2/mysql ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3

    报错环境 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添加以下代码即可。

    #安装pymysql

    pip install pymysql
    
    #__init__.py
    import pymysql
    pymysql.install_as_MySQLdb()

    第一种:
    django降到2.1.4版本就OK了

    第二种(仍使用django 2.2版本):

    1、#找到Python环境下 django包,并进入到backends下的mysql文件夹
    cd /opt/anaconda3/envs/envAGC_Mini/lib/python3.6/site-packages/django/db/backends/mysql


    2、# 找到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行,版本不同行数不同哈~自个儿find一下),将decode改为encode

    if query is not None:
    query = query.decode(errors='replace')
    return query
    #改为
    if query is not None:
    query = query.encode(errors='replace')
    return query

     
    原文:https://blog.csdn.net/weixin_33127753/article/details/89100552

  • 相关阅读:
    http url转义字符,特殊字符
    No bean named &#39;cxf&#39; is defined
    c语言中结构体指针
    Android fragment (二)
    文件I/O之C标准库函数和系统库函数差别
    计算机组成原理——主存与cache的映射关系
    openstack 用nova API 指定 compute node 创建 instance
    SQL存在一个表而不在还有一个表中的数据
    hdu 2602
    小金登陆游戏
  • 原文地址:https://www.cnblogs.com/Leslieblog/p/11120779.html
Copyright © 2011-2022 走看看