• 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()

  • 相关阅读:
    triplet loss 在深度学习中主要应用在什么地方?有什么明显的优势?
    一个评测指标就是MAP(Mean Average Precision)平均精度均值。
    机器学习术语中英对照表
    logistic softmax
    mysql导出导入sql文件方法(linux)
    mysql分区表
    matplotlib安装错误依赖问题解决
    linux命令集合
    linux下安装或升级GCC4.8.2,以支持C++11标准[转]
    linux 如何显示一个文件的某几行(中间几行)
  • 原文地址:https://www.cnblogs.com/zhangtq/p/9728672.html
Copyright © 2020-2023  润新知