试图在Python 3.6.0上使用pip3安装mysqlclient

$ pip3 install mysqlclient
Collecting mysqlclient
  Using cached mysqlclient-1.3.10.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/3k/08g3yx_12kg99kyfs989md600000gn/T/pip-build-1qv_89jc/mysqlclient/setup.py", line 17, in <module>
        metadata, options = get_config()
      File "/private/var/folders/3k/08g3yx_12kg99kyfs989md600000gn/T/pip-build-1qv_89jc/mysqlclient/setup_posix.py", line 54, in get_config
        libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
      File "/private/var/folders/3k/08g3yx_12kg99kyfs989md600000gn/T/pip-build-1qv_89jc/mysqlclient/setup_posix.py", line 54, in <listcomp>
        libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
      File "/private/var/folders/3k/08g3yx_12kg99kyfs989md600000gn/T/pip-build-1qv_89jc/mysqlclient/setup_posix.py", line 12, in dequote
        if s[0] in "\"'" and s[0] == s[-1]:
    IndexError: string index out of range

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/3k/08g3yx_12kg99kyfs989md600000gn/T/pip-build-1qv_89jc/mysqlclient/

已经做到了

brew install mysql-connector-c

但还是会犯这个错误

推荐答案

这对我很有用:

  1. 一百

  2. 编辑mysql_config(找到它:which mysql_config)

在mysql_配置中更正此问题:

# Create options 
libs="-L$pkglibdir"
libs="$libs -l "

应该是:

# Create options 
libs="-L$pkglibdir"
libs="$libs -lmysqlclient -lssl -lcrypto"
  1. brew info openssl
  2. 最后pip3 install mysqlclient

Python-3.x相关问答推荐

动态范围内来自另外两列的列求和

PythonPandas READ_EXCEL空数据帧

当我在正则表达式末尾使用斜杠时,为什么会得到不同的结果?

替换 .txt 文件中的项目列表

PyTest:尽管明确运行了测试,但是被标记为没有运行测试

在Pandas中,根据另一列中的重复值将数据分组为一列

提取图像中的背景并保存

如何在类中的函数(以 self 作为第一个参数)中使用递归

我应该如何调整我的变量,以便如果有任何单词符合其中的条件,程序会将其附加到新列表中?

python2和python3中的列表生成器

在判断列表变量时如何判断特定列的值并分配加权整数值

ImportError:无法从jinja2导入名称escape

pip install mysqlclient 失败为 mysqlclient 运行 setup.py bdist_wheel ... 错误

Django 2 个字段之一不能为空

命名元组内命名元组的 Python 语法

TimescaleDB:是否可以从 Python 调用create_hypertable?

Tkinter AttributeError:对象没有属性'tk'

为什么排序列表比未排序列表大

警告:请使用 tensorflow/models 中的官方/mnist/dataset.py 等替代方案

字典理解中的操作顺序