现象描述

起初正常使用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安装这个包还要这么心累………………

最新文章

  1. (原).NET程序加入多语言包解决方案工具,超级棒
  2. 解决:PADS导入.DXF结构图出现坐标超出范围问题
  3. Linux CentOS 6.6安装JDK1.7
  4. poj1981Circle and Points(单位圆覆盖最多的点)
  5. Spring配置文件解析--bean属性
  6. 多线程程序设计学习(9)worker pattern模式
  7. Eclipse 优化方法(经典收藏)
  8. thinkphp带查询条件的分页
  9. Mysql MHA(GTID)配置(实操)
  10. MySql采用GROUP_CONCAT合并多条数据显示的方法
  11. oracle 10g数据库下的 XDB组件的重新安装
  12. 分布式任务调度平台XXL-JOB搭建教程
  13. Qt 查询字符串数据
  14. linux挂在samba服务器到本地(用于备份文件到nas或者windows的文件服务器)
  15. Boss直聘邮件通知小脚本
  16. 【转载】showModalDialog returnValue is undefined in Google&#160;Chrome
  17. window.onload与$(document).ready()之区别
  18. AngularJs学习笔记--I18n/L10n
  19. C# Hadoop学习笔记(七)—C#的云计算框架借鉴(下)
  20. 【WEB】jQuery获取页面回滚或跳转事件

热门文章

  1. rest framework 之解析器
  2. Prometheus(五):Prometheus+Alertmanager 配置企业微信报警
  3. PAT 乙级 1012.数字分类 C++/Java
  4. 模型融合---为什么说bagging是减少variance,而boosting是减少bias?
  5. 配置nginx的systemctl命令
  6. Gym - 247731E :room(最小费用流裸题)
  7. OpenCV录制视频,播放视频
  8. Activity间通过Intent交互及系统服务调用
  9. win10怎么查看当前用户账号
  10. jQuery--data()方法