现象描述

起初正常使用pip命令提示如下的错误:

cc -bundle -undefined dynamic_lookup -Wl,-F. build/temp.macosx-10.14-intel-2.7/_mysql.o -L/usr/local/Cellar/mysql-connector-c/6.1.11/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.14-intel-2.7/_mysql.so
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'cc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for mysql-python 13 warnings generated.
cc -bundle -undefined dynamic_lookup -Wl,-F. build/temp.macosx-10.14-intel-2.7/_mysql.o -L/usr/local/Cellar/mysql-connector-c/6.1.11/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.14-intel-2.7/_mysql.so
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'cc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /Users/wang/.virtualenvs/flask-demo/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/4r/29z_gj1n4szg9r01y5s6rxnm0000gn/T/pip-install-yqjXkS/mysql-python/setup.py'"'"'; __file__='"'"'/private/var/folders/4r/29z_gj1n4szg9r01y5s6rxnm0000gn/T/pip-install-yqjXkS/mysql-python/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/4r/29z_gj1n4szg9r01y5s6rxnm0000gn/T/pip-record-rW5Hej/install-record.txt --single-version-externally-managed --compile --install-headers /Users/wang/.virtualenvs/flask-demo/include/site/python2.7/mysql-python Check the logs for full command output.

大致来看,是cc命令执行失败,没太多的思路,遂谷歌;

尝试

stackoverflow答案

https://stackoverflow.com/questions/50940302/installing-mysql-python-causes-command-clang-failed-with-exit-status-1-on-mac

参考上面的链接,执行了一下,甚至也执行了一次评论里的内容,但实际上并没啥用……

后面甚至出现了新的问题……

csdn答案

https://blog.csdn.net/love_parents/article/details/80938818

尝试了后,又提示其他的问题

ERROR: Command errored out with exit status 1:
command: /Users/wang/.virtualenvs/flask-demo/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/4r/29z_gj1n4szg9r01y5s6rxnm0000gn/T/pip-install-xonLuB/mysql-python/setup.py'"'"'; __file__='"'"'/private/var/folders/4r/29z_gj1n4szg9r01y5s6rxnm0000gn/T/pip-install-xonLuB/mysql-python/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/4r/29z_gj1n4szg9r01y5s6rxnm0000gn/T/pip-install-xonLuB/mysql-python/pip-egg-info
cwd: /private/var/folders/4r/29z_gj1n4szg9r01y5s6rxnm0000gn/T/pip-install-xonLuB/mysql-python/
Complete output (9 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/4r/29z_gj1n4szg9r01y5s6rxnm0000gn/T/pip-install-xonLuB/mysql-python/setup.py", line 17, in <module>
metadata, options = get_config()
File "setup_posix.py", line 53, in get_config
libraries = [ dequote(i[2:]) for i in libs if i.startswith(compiler_flag("l")) ]
File "setup_posix.py", line 8, in dequote
if s[0] in "\"'" and s[0] == s[-1]:
IndexError: string index out of range
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

这个问题,在此篇文章有提到,但按照他的方法并不能解决,遂继续谷歌

最终解决办法

https://www.cnblogs.com/LordNeo/p/9687832.html

参考这篇文章执行了重新安装了 mysql-connector-c ,修改了mysql的配置文件;

执行了brew info openssl,得到

(flask-demo) ➜  homebrew-core git:(master) brew info openssl
openssl: stable 1.0.2t (bottled) [keg-only]
SSL/TLS cryptography library
https://openssl.org/
/usr/local/Cellar/openssl/1.0.2t (1,795 files, 12.0MB)
Poured from bottle on 2019-10-30 at 18:26:15
From: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git/Formula/openssl.rb
==> Caveats
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), place .pem files in
/usr/local/etc/openssl/certs and run
/usr/local/opt/openssl/bin/c_rehash openssl is keg-only, which means it was not symlinked into /usr/local,
because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries. If you need to have openssl first in your PATH run:
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.zshrc For compilers to find openssl you may need to set:
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include" For pkg-config to find openssl you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"

随后执行了提示里的 echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.zshrc

同时,把下面语句加入了 bash_profile 并source bash_profile。

  export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"

再使用 pip安装,成功了……

后记

都2019年了,Mac/Linux安装这个包还要这么心累………………

Mac安装MySQL-python的血泪史的更多相关文章

  1. mac安装mysql及终端操作mysql与pycharm的数据库可视化

    一.Mac安装mysql 首先下载mysql,地址:https://dev.mysql.com/downloads/mysql/ 然后已知安装就好了,会出现让你记住密码的提示,然后就安装好了.... ...

  2. mac安装mysql数据库及配置环境变量

    mac安装mysql数据库及配置环境变量 mac安装mysql数据库及配置环境变量 原文文链接:https://blog.csdn.net/qq_36004521/article/details/80 ...

  3. mac 安装mysql + 修改root用户密码 + 及报Access denied for user 'root'@'localhost' (using password:YES)解决办法

    1.下载MySQL 到mysql的官网http://dev.mysql.com/downloads/mysql/然后在页面中会看到“MySQL Community Server”下方有一个“downl ...

  4. Mac 安装 MySQL

    在 Mac 下用 Homebrew 安装 MySQL, 网上的教程倒是很多,不过大多数都很默契地雷同.如果稍有点定制要求,就无从下手了. 我先也不免俗,从基本的开始: 一.首先安装 Homebrew ...

  5. Install MySQL on Mac OS X——MAC安装MySQL

    很多关于如何安装MySQL的教程已经过时了,或者比必须的步骤复杂得多.这篇教程将展示如何安装MySQL,启动MySQL,以root用户进入MySQL,以及创建删除退出数据库. Step 1: 下载My ...

  6. Mac安装Mysql无法登录

    Mac安装的Mysql5.7.10 执行mysql -u root -p 就要求输入密码,但是新安装是没密码的.然后就会报错. ERROR 1045 (28000): Access denied fo ...

  7. mac 安装mysql 修改密码

    我草!!! 上网查资料,安装mysql,一大推废话,简直就是他妈的瞎扯淡,真是能他妈的瞎编,草! 为了不让后面的同学看到那些狗屁不通的资料,我把自己安装mysql的步骤,以及修改mysql密码的方法梳 ...

  8. mac安装mysql的两种方法(含配置)

    1.使用安装包安装mysql 双击打开安装文件 双击pkg文件安装 一路向下,记得保存最后弹出框中的密码(它是你mysql root账号的密码) 正常情况下,安装成功. 此时只是安装成功,但还需要额外 ...

  9. mac安装mysql及workbench

    安装mysql 登录MySQL网站 打开网站Download MySQL Community Server,选择下方的dmg文件下载 点击download,此处为8.0.11版本 然后选择no tha ...

  10. mac 安装 mysql 配置

    前言:下面主要介绍2种安装方法以及后续的配置,希望对大家有帮助.(推荐通过安装包的形式安装) 1. 使用安装包安装 mysql 双击打开安装文件         双击pkg文件安装         一 ...

随机推荐

  1. MySQL 5.7数据库参数优化

    连接相关参数 max_connections:允许客户端并发连接的最大数量,默认值是151,一般将该参数设置为500-2000max_connect_errors:如果客户端尝试连接的错误数量超过这个 ...

  2. Java httpclent请求httpclentUtils工具类

    第一种写法: import java.io.IOException; import java.io.InterruptedIOException; import java.io.Unsupported ...

  3. Python卸载不干净?苹果电脑卸载python教程

    如今,Pyhon越来越火,屡次超越Java.C++成为编程语言排行榜第一的语言,国内的公司和程序员们也越来越喜欢使用Python.但是Python安装之后,散落在电脑各处,删除起来比较麻烦,很多小伙伴 ...

  4. spring cloud微服务实战教程/pdf/视频/百度云资源

    资源站:http://www.supan.vip 点击进入直接查找资源: http://www.supan.vip/spring%20cloud微服务实战 <Spring Cloud微服务实战& ...

  5. find 和grep的区别

    find(以文件属性为查找条件) grep(以文件内容为查找条件) grep works /usr/local/apache/htdocs/index.html 1.将/etc/passwd,有出现 ...

  6. Gitlab修改IP后,配置更改

    gitlab 服务器在修改了IP地址之后,面对需要修改配置的问题,否则每个项目的 git网址显示是老IP.从网上搜索了不少修改教程,发现基本都是修改 /opt/gitlab/embedded/serv ...

  7. 【转】大众点评Cat--架构分析

    https://blog.csdn.net/szwandcj/article/details/51025669 Cat功能强大且多,光日志的报表和图表分析就有十几种,但文档却很少,寥寥无几找到一些粒度 ...

  8. Dapper: How to get return value ( output value) by call stored procedure

    使用Dapper 执行存储过程插入一条数据,同时返回主键 Dapper 的参数类型有以下四种 System.Data.ParameterDirection public enum ParameterD ...

  9. 性能测试基础---LR关联2

    ·LR中的关联函数详解.在LR中,用于关联的函数一般有以下四个:web_reg_save_param 是通过字符串查找的方式来查找获取数据.web_reg_save_param_ex 是通过字符串查找 ...

  10. Chrome出现“浏览器由所属组织管理”如何解决

    之前碰到了这个问题,删除注册表解决了.当时没记下来,今天又碰到了.那就写下来以备之后再碰到吧 删除了注册表\HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Ch ...