python - MySQLClient 安装错误 : "raise Exception("Wrong MySQL configuration: maybe https://bugs. mysql.com/bug.php?id"

标签 python mysql mysql-python

我正在尝试将 mysqlclient 安装到我的 Python 3.6 上。最初我想安装的是 MySQLdb,但是它说 MySQLdb 不能与 Python 3 一起使用(还是?)。所以我切换到mysqlclient。

pip3 install mysqlclient

但是,出现了以下错误:

    Collecting mysqlclient
  Using cached https://files.pythonhosted.org/packages/ec/fd/83329b9d3e14f7344d1cb31f128e6dbba70c5975c9e57896815dbb1988ad/mysqlclient-1.3.13.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/h3/sff7td1d6pg5v5qsm5xf31q80000gn/T/pip-install-ki9z7ln9/mysqlclient/setup.py", line 18, in <module>
        metadata, options = get_config()
      File "/private/var/folders/h3/sff7td1d6pg5v5qsm5xf31q80000gn/T/pip-install-ki9z7ln9/mysqlclient/setup_posix.py", line 60, in get_config
        libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
      File "/private/var/folders/h3/sff7td1d6pg5v5qsm5xf31q80000gn/T/pip-install-ki9z7ln9/mysqlclient/setup_posix.py", line 60, in <listcomp>
        libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
      File "/private/var/folders/h3/sff7td1d6pg5v5qsm5xf31q80000gn/T/pip-install-ki9z7ln9/mysqlclient/setup_posix.py", line 13, in dequote
        raise Exception("Wrong MySQL configuration: maybe https://bugs.mysql.com/bug.php?id=86971 ?")
    Exception: Wrong MySQL configuration: maybe https://bugs.mysql.com/bug.php?id=86971 ?

我可以知道我应该做什么来解决这个问题吗?

最佳答案

这是自 2017 年 11 月以来的一个错误。 我遇到了同样的错误,这就是有帮助的:

  1. 对 mysqlclient-python 或 mysql-connector-c 或 libmysqlclient 中的 mysql_config 文件进行更改(取决于您使用的内容)

    改变

    # on macOS, on or about line 112:
    # Create options
    libs="-L$pkglibdir"
    libs="$libs -l "

至:

    # Create options
    libs="-L$pkglibdir"
    libs="$libs -lmysqlclient -lssl -lcrypto"
  • 将以下内容添加到 .bash_profile 的末尾 how to do that :
  •    export PATH="/usr/local/opt/openssl/bin:$PATH"
       export LDFLAGS="-L/usr/local/opt/openssl/lib"
       export CPPFLAGS="-I/usr/local/opt/openssl/include"
    
  • 运行pip install mysqlclient,现在应该可以工作了。
  • 欲了解更多信息,请查看 this link ,请参阅“关于 macOS 上 MySQL Connector/C 的 bug 的说明”部分。

    关于python - MySQLClient 安装错误 : "raise Exception("Wrong MySQL configuration: maybe https://bugs. mysql.com/bug.php?id",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53856638/

    相关文章:

    python - Scrapy收集数据,但不将其保存到项目中

    python - 每个进程的速度随着进程的增加而变慢

    php - 如何向MySQL数据库插入微秒?

    python - 更改记录查询中的隔离级别或关闭事务

    mysql - 为什么 MYSQL IN 关键字不考虑 NULL 值

    python - argparse 位置参数的位置

    python - 如何获取JSON格式的 Graphite 树结构

    mysql - 如果标题 1 在 MySQL 中不存在,则选择标题 2

    使用 SUM() 的 MySQL 查询未返回预期结果

    python - MySQL删除查询不执行