MacOS10.14,python安装Mysql-python出错,报ld: library not found for -lssl

解决方法:

  1. 先确认是否安装mysql,如果没装,可以通过 brew install MySQL(有点慢),也可以下载dmg来安装
  2. pip intall Mysql-python 出错,如果错误信息是 ld: library not found for -lssl,可以执行以下命令:
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

原因:

MacOS新版本,默认是没有Command Line Tools的,同时因为安全性原因 /usr/include 文件夹也没有,也不会给权限给我们编辑,可以通过 macOS_SDK_headers_for_macOS_10.14.pkg 帮我们安装一些 header头文件。

错误日志:

$ pip install MySQL-python
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting MySQL-python
..........
....省略很多日志
..........
                                        ~ ^~~~~~~~~~~
    _mysql.c:1506:11: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
                                    len = strlen(buf);
                                        ~ ^~~~~~~~~~~
    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@5.7/5.7.26/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 "/usr/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/private/var/folders/zw/57wvjchn72n_gq259cjskt_c0000gn/T/pip-install-OOFRzg/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/zw/57wvjchn72n_gq259cjskt_c0000gn/T/pip-record-NXkl0u/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/zw/57wvjchn72n_gq259cjskt_c0000gn/T/pip-install-OOFRzg/MySQL-python/
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值