这是一个来自mysql官方的bug,反正我是看不懂。
shuais-MBP:wxapp dandyzhang$ pipenv install mysqlclient Installing 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/rw/kmt8v6lj2fb37k0kh1ggm4m40000gn/T/pip-install-rwvfazf6/mysqlclient/setup.py", line 18, in <module> metadata, options = get_config() File "/private/var/folders/rw/kmt8v6lj2fb37k0kh1ggm4m40000gn/T/pip-install-rwvfazf6/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/rw/kmt8v6lj2fb37k0kh1ggm4m40000gn/T/pip-install-rwvfazf6/mysqlclient/setup_posix.py", line 60, in <listcomp> libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')] File "/private/var/folders/rw/kmt8v6lj2fb37k0kh1ggm4m40000gn/T/pip-install-rwvfazf6/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 ? ---------------------------------------- Error: An error occurred while installing mysqlclient! Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/rw/kmt8v6lj2fb37k0kh1ggm4m40000gn/T/pip-install-rwvfazf6/mysqlclient/ This is likely caused by a bug in mysqlclient. Report this to its maintainers.
mysqlclient的作者在源码里已经写了个exception是专门针对这个报错的,就是上面加粗的那一句黑色的链接
Wrong MySQL configuration: maybe https://bugs.mysql.com/bug.php?id=86971 ?
它说,错误的mysql配置,可能是链接里的问题。
这里就不打开链接了解释了,反正就是一个官方的bug,里面也写了怎么解决。
首先安装mysql-connector
brew install mysql-connector-c
然后修改一下mysql_config文件,当然基于安全性的考虑需要先备份一下文件
cp /usr/local/bin/mysql_config /usr/local/bin/mysql_config.backup
然后修改文件
sudo vim /usr/local/bin/mysql_config
找到对应的内容位置
# Create options libs="-L$pkglibdir" libs="$libs -l " 修改成 # Create options libs="-L$pkglibdir" libs="$libs -lmysqlclient -lssl -lcrypto"
这时候安装mysqlclient就没问题了。。