zoukankan      html  css  js  c++  java
  • Python2安装数据库驱动(Mysql_Python)失败问题

    报错信息如下:

     File "D:Projectmegatech.aivenvlibsite-packagesdjangocontribauthmodels.py", line 4, in <module>
        from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
      File "D:Projectmegatech.aivenvlibsite-packagesdjangocontribauthase_user.py", line 52, in <module>
        class AbstractBaseUser(models.Model):
      File "D:Projectmegatech.aivenvlibsite-packagesdjangodbmodelsase.py", line 124, in __new__
        new_class.add_to_class('_meta', Options(meta, app_label))
      File "D:Projectmegatech.aivenvlibsite-packagesdjangodbmodelsase.py", line 325, in add_to_class
        value.contribute_to_class(cls, name)
      File "D:Projectmegatech.aivenvlibsite-packagesdjangodbmodelsoptions.py", line 214, in contribute_to_class
        self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
      File "D:Projectmegatech.aivenvlibsite-packagesdjangodb\__init__.py", line 33, in __getattr__
        return getattr(connections[DEFAULT_DB_ALIAS], item)
      File "D:Projectmegatech.aivenvlibsite-packagesdjangodbutils.py", line 211, in __getitem__
        backend = load_backend(db['ENGINE'])
      File "D:Projectmegatech.aivenvlibsite-packagesdjangodbutils.py", line 115, in load_backend
        return import_module('%s.base' % backend_name)
      File "C:PythonPython27Libimportlib\__init__.py", line 37, in import_module
        __import__(name)
      File "D:Projectmegatech.aivenvlibsite-packagesdjangodbackendsmysqlase.py", line 30, in <module>
        'Did you install mysqlclient or MySQL-python?' % e
    django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb.
    Did you install mysqlclient or MySQL-python?

     解决方案:

    1.安装pymysql的包

    2.在项目的init文件中添加如下代码

    # import pymysql
    # pymysql.install_as_MySQLdb()

  • 相关阅读:
    Thinkpad R400无线网络一个都不见了!
    如果使用安卓4.4的SD卡?
    如何使用安卓4.4的SD卡?
    在IAR使用FreeRTOS出现Error[Pa045]: function "XXX" has no prototype
    DSP5509的RTC实验-第3篇
    LWM2M简介-学习记录
    DSP5509的定时器实验-第2篇
    DSP5509的XF实验-第一篇
    华为LiteOS系统使用-任务调度函数-第一篇
    2017-12-24自选的股票之春秋航空
  • 原文地址:https://www.cnblogs.com/zhangtq/p/9728672.html
Copyright © 2011-2022 走看看