Mac pipenv install mysqlclient failed解决方案

本文档介绍了在Mac上使用pipenv安装mysqlclient时遇到的问题及解决方案。在尝试安装过程中,可能会遇到错误,解决方法包括确保已安装MySQL,修改.bash_profile文件并添加相关路径,然后重新执行安装命令,最终成功安装。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原文地址

问题

当执行

pipenv install mysqlclient

出现如下错误

An error occurred while installing mysqlclient==1.3.13!
...
...
...
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1
...
...
...

解决方案

  1. 首先确保你的mac上安装了mysql
brew install/upgrade/reinstall mysql
  1. 在terminal下输入下面内容
brew info openssl
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"' >> ~/.bash_profile

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"
  1. 根据提示在.bash_profile中添加
export PATH="/usr/local/opt/openssl/bin:$PATH"

在这里插入图片描述
然后执行

source ~/.bash_profile
  1. 在terminal中执行
  export LDFLAGS="-L/usr/local/opt/openssl/lib"
  export CPPFLAGS="-I/usr/local/opt/openssl/include"

最后安装成功

$ export LDFLAGS="-L/usr/local/opt/openssl/lib"
$ export CPPFLAGS="-I/usr/local/opt/openssl/include"
$ pipenv install mysqlclient
Collecting mysqlclient
  Using cached https://files.pythonhosted.org/packages/4d/38/c5f8bac9c50f3042c8f05615f84206f77f03db79781db841898fde1bb284/mysqlclient-1.4.4.tar.gz
Building wheels for collected packages: mysqlclient
  Building wheel for mysqlclient (setup.py) ... done
  Created wheel for mysqlclient: filename=mysqlclient-1.4.4-cp37-cp37m-macosx_10_14_x86_64.whl size=55994 sha256=a0b1b9a250b60d438ca74ba20c15ac210fccb4a39ebe68aa3c62470a8ca70713
  Stored in directory: /Users/rhm/Library/Caches/pip/wheels/a0/04/57/031b9b01df38999df7dc7f4ee998a98ecdbd2d781f73e3ffbf
Successfully built mysqlclient
Installing collected packages: mysqlclient
Successfully installed mysqlclient-1.4.4
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值