无法加载mysql插件:找不到指定的模块

时间:2019-02-13 03:47:23

标签: python mysql django python-3.x django-database

我正在使用pipenv来遵循“编写您的第一个Django应用程序”教程,并且陷入part 2的困境。我已经启动并运行了一个AWS免费套餐MySQL数据库,并且正在尝试配置我的应用程序以连接到MySQL而不是SQLite。每当我尝试前进并使用该页面上列出的python manage.py migrate命令时,都会出现上述错误(在本文章底部的完整堆栈跟踪)。当我只是尝试像第1部分中那样python manage.py runserver时,也会发生这种情况。

我尝试搜索堆栈跟踪最后一行的所有不同部分django.db.utils.OperationalError: (2059, "Plugin mysql could not be loaded: The specified module could not be found. Library path is 'lib/mariadb/plugin/mysql.dll'"),所有搜索都使我进入了不相关的资源,例如GIS应用程序和tons }}条将我定向到tons的帖子。尽管这些错误都没有具体地与我的错误相匹配,但我仍在假设可能存在错误的情况被掩埋在某个地方,因此值得一试。我检查了现有用户,根据MySQL Workbench,该用户具有“标准”身份验证类型。也许是这样,所以我迅速创建了一个具有相同权限的新用户,并允许与第一个主机相同的主机,但是这次身份验证类型设置为“ SHA256密码”。同样的错误。

好的,下一个选项。也许虚拟环境以某种方式被搞砸了。删除并重建环境,重新安装依赖项pip run python manage.py runserver。同样的错误。我注意到我正在运行Python 3.6 x86,因此我再次删除了环境,安装了Python 3.7 x64,升级了pip,安装了pipenv,重建了环境,并重新安装了依赖项。同样的错误。

好的,是时候安装Oracle的MySQL Web安装程序,看看它可能会做什么。更新已安装的内容,安装Python,C和C ++连接器,然后再次删除/重建环境。再一次,我遇到了同样的错误。我删除了除工作台以外的所有MySQL,然后下载常规安装程序并尝试再次获取连接器。我再次删除/重建环境,仍然出现相同的错误。

绝望的最后一步:

  • 使用look at my authentication method在硬盘上查找名称为mysql.dll的任何地方,这些地方可能在错误的位置(没有结果)
  • 使用Notepad ++出色的“查找文件”功能在虚拟环境中查找所有文件中的所有路径段(无结果)
  • 查看在堆栈跟踪中提供行号的最后一行,请参阅connections.py:164,并尝试跟踪我的方法以查找甚至从哪里提取方法的地方(无结果)

由于Google让我失败了,我求助于你们。有没有人遇到这个问题或看到一个相关的问题?我尝试包括所有我认为有用的信息,但是如果还有其他有用的信息,请询问。

感谢您的时间,并度过了一个美好的早晨/白天/夜晚。

操作系统:Windows 10.0.17763.253

体系结构:64位

MySQL版本:5.7.23

MySQL Workbench版本:8.0.15

Python版本:3.7.0

Django版本:2.1.7

mysqlclient版本:1.4.1

命令:pipenv run python manage.py runserver

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'django_tutorial',
        'HOST': 'elided',
        'USER': 'elided',
        'PASSWORD': 'elided'
    }
}

错误堆栈跟踪:

    Traceback (most recent call last):
  File "C:\Users\Mr. Nakaan\.virtualenvs\python-i3rFUgWM\lib\site-packages\django\db\backends\base\base.py", line 216, in ensure_connection
    self.connect()
  File "C:\Users\Mr. Nakaan\.virtualenvs\python-i3rFUgWM\lib\site-packages\django\db\backends\base\base.py", line 194, in connect
    self.connection = self.get_new_connection(conn_params)
  File "C:\Users\Mr. Nakaan\.virtualenvs\python-i3rFUgWM\lib\site-packages\django\db\backends\mysql\base.py", line 227, in get_new_connection
    return Database.connect(**conn_params)
  File "C:\Users\Mr. Nakaan\.virtualenvs\python-i3rFUgWM\lib\site-packages\MySQLdb\__init__.py", line 84, in Connect
    return Connection(*args, **kwargs)
  File "C:\Users\Mr. Nakaan\.virtualenvs\python-i3rFUgWM\lib\site-packages\MySQLdb\connections.py", line 164, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
MySQLdb._exceptions.OperationalError: (2059, "Plugin mysql could not be loaded: The specified module could not be found. Library path is 'lib/mariadb/plugin/mysql.dll'")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "wetpages\manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Users\Mr. Nakaan\.virtualenvs\python-i3rFUgWM\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "C:\Users\Mr. Nakaan\.virtualenvs\python-i3rFUgWM\lib\site-packages\django\core\management\__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\Mr. Nakaan\.virtualenvs\python-i3rFUgWM\lib\site-packages\django\core\management\base.py", line 316, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\Mr. Nakaan\.virtualenvs\python-i3rFUgWM\lib\site-packages\django\core\management\base.py", line 350, in execute
    self.check()
  File "C:\Users\Mr. Nakaan\.virtualenvs\python-i3rFUgWM\lib\site-packages\django\core\management\base.py", line 379, in check
    include_deployment_checks=include_deployment_checks,
  File "C:\Users\Mr. Nakaan\.virtualenvs\python-i3rFUgWM\lib\site-packages\django\core\management\commands\migrate.py", line 59, in _run_checks
    issues = run_checks(tags=[Tags.database])
  File "C:\Users\Mr. Nakaan\.virtualenvs\python-i3rFUgWM\lib\site-packages\django\core\checks\registry.py", line 71, in run_checks
    new_errors = check(app_configs=app_configs)
  File "C:\Users\Mr. Nakaan\.virtualenvs\python-i3rFUgWM\lib\site-packages\django\core\checks\database.py", line 10, in check_database_backends
    issues.extend(conn.validation.check(**kwargs))
  File "C:\Users\Mr. Nakaan\.virtualenvs\python-i3rFUgWM\lib\site-packages\django\db\backends\mysql\validation.py", line 9, in check
    issues.extend(self._check_sql_mode(**kwargs))
  File "C:\Users\Mr. Nakaan\.virtualenvs\python-i3rFUgWM\lib\site-packages\django\db\backends\mysql\validation.py", line 13, in _check_sql_mode
    with self.connection.cursor() as cursor:
  File "C:\Users\Mr. Nakaan\.virtualenvs\python-i3rFUgWM\lib\site-packages\django\db\backends\base\base.py", line 255, in cursor
    return self._cursor()
  File "C:\Users\Mr. Nakaan\.virtualenvs\python-i3rFUgWM\lib\site-packages\django\db\backends\base\base.py", line 232, in _cursor
    self.ensure_connection()
  File "C:\Users\Mr. Nakaan\.virtualenvs\python-i3rFUgWM\lib\site-packages\django\db\backends\base\base.py", line 216, in ensure_connection
    self.connect()
  File "C:\Users\Mr. Nakaan\.virtualenvs\python-i3rFUgWM\lib\site-packages\django\db\utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "C:\Users\Mr. Nakaan\.virtualenvs\python-i3rFUgWM\lib\site-packages\django\db\backends\base\base.py", line 216, in ensure_connection
    self.connect()
  File "C:\Users\Mr. Nakaan\.virtualenvs\python-i3rFUgWM\lib\site-packages\django\db\backends\base\base.py", line 194, in connect
    self.connection = self.get_new_connection(conn_params)
  File "C:\Users\Mr. Nakaan\.virtualenvs\python-i3rFUgWM\lib\site-packages\django\db\backends\mysql\base.py", line 227, in get_new_connection
    return Database.connect(**conn_params)
  File "C:\Users\Mr. Nakaan\.virtualenvs\python-i3rFUgWM\lib\site-packages\MySQLdb\__init__.py", line 84, in Connect
    return Connection(*args, **kwargs)
  File "C:\Users\Mr. Nakaan\.virtualenvs\python-i3rFUgWM\lib\site-packages\MySQLdb\connections.py", line 164, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
django.db.utils.OperationalError: (2059, "Plugin mysql could not be loaded: The specified module could not be found. Library path is 'lib/mariadb/plugin/mysql.dll'")

0 个答案:

没有答案