Mac 安装mysqlclient报错 的相关解决方案

报错的相关信息:

Collecting mysqlclient
  Using cached mysqlclient-2.1.1.tar.gz (88 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [16 lines of output]
      /bin/sh: mysql_config: command not found
      /bin/sh: mariadb_config: command not found
      /bin/sh: mysql_config: command not found
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/private/var/folders/4l/9fx5h98x5z1fh9vy4h6phhy80000gn/T/pip-install-1y992754/mysqlclient_664ebe7b4953400db5829a6b8e4b4784/setup.py", line 15, in <module>
          metadata, options = get_config()
        File "/private/var/folders/4l/9fx5h98x5z1fh9vy4h6phhy80000gn/T/pip-install-1y992754/mysqlclient_664ebe7b4953400db5829a6b8e4b4784/setup_posix.py", line 70, in get_config
          libs = mysql_config("libs")
        File "/private/var/folders/4l/9fx5h98x5z1fh9vy4h6phhy80000gn/T/pip-install-1y992754/mysqlclient_664ebe7b4953400db5829a6b8e4b4784/setup_posix.py", line 31, in mysql_config
          raise OSError("{} not found".format(_mysql_config_path))
      OSError: mysql_config not found
      mysql_config --version
      mariadb_config --version
      mysql_config --libs
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

解决方案:

1、安装mysql-client

brew install mysql-client

2、给mysql-client配置环境

#通过以下命令找到mysql-client 的相关位置
locate mysql-client

#找到以下目录
/opt/homebrew/Cellar/mysql-client/8.0.30/bin
#打开.zshrc文件
open .zshrc

#配置环境变量,添加以下语句到zshrc文件下
export PATH="/opt/homebrew/Cellar/mysql-client/8.0.30/bin:$PATH"

3、安装myqlclient

pip install mysqlclient

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值