zoukankan      html  css  js  c++  java
  • Django连接MySQL出错

    错误一:No module named 'MySQLdb'

    原因:python3连接MySQL不能再使用mysqldb,取而代之的是pymysql。

    解决方法:在python的MySQL包中,即路径:C:UsersadongAppDataLocalProgramsPythonPython36Libsite-packagesDjango-2.0.3-py3.6.eggdjangodbackendsmysql

    下的__init__.py文件中加入:

    import pymysql

    pymysql.install_as_MySQLdb()

    错误二:django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.3 or newer is required; you have 0.7.11.None

    原因:在解决了错误一以后出现了此错误。

    解决方法:在python的MySQL包中,即路径:C:UsersadongAppDataLocalProgramsPythonPython36Libsite-packagesDjango-2.0.3-py3.6.eggdjangodbackendsmysql

    下的 base.py 文件中,注释掉一下两行代码:

    if version < (1, 3, 3):
         raise ImproperlyConfigured("mysqlclient 1.3.3 or newer is required; you have %s" % Database.__version__) 

    已解决: 1、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.   解决办法:C:Python37Libsite-packagesdjangodbackendsmysql(python安装目录)打开base.py,注释掉以下内容:        

    if version < (1, 3, 13):           

    raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)   

    2、File "C:Python37libsite-packagesdjangodbackendsmysqloperations.py",

    line 146, in last_executed_query   

    query = query.decode(errors='replace')   

    AttributeError: 'str' object has no attribute 'decode'  

     解决办法:打开此文件把146行的decode修改为encode

  • 相关阅读:
    IDEA运行测试错误Failed to resolve org.junit.platform:junit-platform-launcher
    mysql索引基本原理
    as3.0声音波形系列03_十组合
    as3.0声音波形系列02_六组合
    as3.0声音波形系列01_八组合
    FiltersEffect(效果)
    AS3 TransitionManager 自带特效类
    as3 判断鼠标移动方向
    AS3代码生成xml方法
    求线段的交点
  • 原文地址:https://www.cnblogs.com/sky-ai/p/11024209.html
Copyright © 2011-2022 走看看