Macos编译mysql-python报错 ld: library not found for -lssl

首先,我通过: 

pip install mysql-python

然后报错

_mysql.c:1504:11: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
                                  len = strlen(buf);
                                      ~ ^~~~~~~~~~~
  _mysql.c:1506:11: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
                                  len = strlen(buf);
                                      ~ ^~~~~~~~~~~
  15 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.6/5.6.43/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

其中,主要报错:

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

原因分析:

安装过程中,无法找到openssl文件

由于苹果公司已经放弃openssl加密转而使用自家的加密方式,导致mac上面是没有oepnssl的,所以需要

# 安装openssl
brew install openssl
# 如果已经安装
brew upgrade openssl
# 如果还不行
xcode-select --install

如果还不行(例如我),那么直接在pip的时候链接brew的openssl,记得用上不使用缓存模式

env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip --no-cache install mysql-python==1.2.5

ok!

结果如下:

Collecting mysql-python==1.2.5
  Downloading https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip (108kB)
     |████████████████████████████████| 112kB 26kB/s 
Building wheels for collected packages: mysql-python
  Building wheel for mysql-python (setup.py) ... done
  Created wheel for mysql-python: filename=MySQL_python-1.2.5-cp27-cp27m-macosx_10_14_intel.whl size=43965 sha256=a67ff16500c2a8a2690ffae0f5a3be3c3271ec2d273c258bded1ea38efc6d6d8
  Stored in directory: /private/tmp/pip-ephem-wheel-cache-enjEof/wheels/07/d2/5f/314860e4cb53a44bf0ee0d051d4b34465e4b4fbe9de6d42f42
Successfully built mysql-python
Installing collected packages: mysql-python
Successfully installed mysql-python-1.2.5

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值