环境介绍

python=3.11.9
pip=24.0
mysql=5.5
系统=centos7

错误信息

  File "<string>", line 155, in <module>
    File "<string>", line 49, in get_config_posix
    File "<string>", line 28, in find_package_name
  Exception: Can not find valid pkg-config name.
  Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> See above for output.
  
  note: This error originates from a subprocess, and is likely not a problem with pip.

解决

这个问题猜测可能是因为mysqlclient需要的mysql一些库文件不对应,因此安装mysql8的一些东西

  • 1.从mysql官网下载mysql源码

  • mysql-8.4.0-1.el7.x86_64.rpm-bundle.tar 在这里插入图片描述

  • 2.解压:

tar -xvf mysql-8.4.0-1.el7.x86_64.rpm-bundle.tar -C mysql8 #j解压到mysql8目录,得到如下文件

在这里插入图片描述

  • 3.安装上图中标记的那个文件

yum localinstall mysql-community-server-8.4.0-1.el7.x86_64.rpm

然后最后再安装mysqlclient顺利完成,如果你的系统上已经有了数据库,上面的操作并不会影响之前的数据库

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐