您的位置:首页 > 新闻 > 热点要闻 > Rocky Linux 9安装mysqlclient库报错的解决方法

Rocky Linux 9安装mysqlclient库报错的解决方法

2025/1/15 15:45:11 来源:https://blog.csdn.net/pcj_888/article/details/142304389  浏览:    关键词:Rocky Linux 9安装mysqlclient库报错的解决方法

环境

VMware Rocky Linux 9.4 MySQL 8.0

安装mysqlclient报错

yum install python3-devel
pip3 install mysqlclient

报错:

Downloading http://mirrors.aliyun.com/pypi/packages/37/fb/d9a8f763c84f1e789c027af0ffc7dbf94c9a38db961484f253f0552cbb47/mysqlclient-2.2.1.tar.gz (89 kB)|████████████████████████████████| 89 kB 80.1 MB/sInstalling build dependencies ... doneGetting requirements to build wheel ... errorERROR: Command errored out with exit status 1:command: /usr/bin/python3 /usr/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py get_requires_for_build_wheel /tmp/tmp5fvp1daucwd: /tmp/pip-install-1nnewfot/mysqlclient_93347d191d2942c8b2bb37681a22fd09Exception: Can not find valid pkg-config name.Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually

解决方法

需要先安装mysql-devel这个RPM包,再用pip安装mysqlclient,操作如下:
在 https://dev.mysql.com/downloads/repo/yum/ 找到MySQL 8.0版本对应的mysql84-community-release-el9-1.noarch.rpm,把这个RPM包拷到VM里手动安装

rpm -i mysql84-community-release-el9-1.noarch.rpm
yum install -y python3-devel mysql-devel
pip3 install mysqlclient

pip list 命令查看已安装的mysqlclient信息

pip list  | grep mysqlclient
mysqlclient         2.2.4

参考

https://stackoverflow.com/questions/76585758/mysqlclient-cannot-install-via-pip-cannot-find-pkg-config-name-in-ubuntu

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com