问题
系统是centos7
需要在python3中安装mysqlclient库
使用 pip3 install mysqlclient
然后无法安装
报错
Looking in indexes: https://pypi.douban.com/simple/
Collecting mysqlclient
Using cached https://mirrors.cloud.tencent.com/pypi/packages/37/fb/d9a8f763c84f1e789c027af0ffc7dbf94c9a38db961484f253f0552cbb47/mysqlclient-2.2.1.tar.gz (89 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [24 lines of output]
Trying pkg-config --exists mysqlclient
Command 'pkg-config --exists mysqlclient' returned non-zero exit status 1.
Trying pkg-config --exists mariadb
Command 'pkg-config --exists mariadb' returned non-zero exit status 1.
Trying pkg-config --exists libmariadb
Command 'pkg-config --exists libmariadb' returned non-zero exit status 1.
Traceback (most recent call last):
File "/root/pythonProject/mengma/venv/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
main()
File "/root/pythonProject/mengma/venv/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/root/pythonProject/mengma/venv/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
return hook(config_settings)
File "/tmp/pip-build-env-5qvzmik9/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
File "/tmp/pip-build-env-5qvzmik9/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
self.run_setup()
File "/tmp/pip-build-env-5qvzmik9/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 311, in run_setup
exec(code, locals())
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
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
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.
关于这个报错显示,参考了好几篇博客,都是在说缺少 mysql-devel 库,用 yum -y install mysql-devel,在使用pip3安装就可了。
但是实际上并没有什么卵用,后来发现,安装的居然是mariadb-devel,跟mysql并没关系。
$ yum install mysql-devel
已加载插件:fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Loading mirror speeds from cached hostfile
* base: mirrors.ustc.edu.cn
* development: mirrors.163.com
* epel: mirror.01link.hk
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
软件包 1:mariadb-devel-5.5.68-1.el7.x86_64 已安装并且是最新版本
无须任何处理
检查
使用 rpm -qa
查看操作系统中是否安装过mysql数据库
$ rpm -qa | grep mysql
$ rpm -qa | grep mariadb
mariadb-5.5.68-1.el7.x86_64
mariadb-devel-5.5.68-1.el7.x86_64
mariadb-libs-5.5.68-1.el7.x86_64
使用rpm 命名查看操作系统中存在mariadb数据库,但是不存在mysql数据库
解决
使用 rpm -e
卸载操作系统中的mariadb数据库
$ rpm -e mariadb-devel
$ rpm -e mariadb-libs
$ rpm -e mariadb
有被依赖,也需要一一卸载
例如
$ rpm -e mariadb-libs
错误:依赖检测失败:
libmysqlclient.so.18()(64bit) 被 (已安裝) postfix-2:2.10.1-9.el7.x86_64 需要
libmysqlclient.so.18(libmysqlclient_18)(64bit) 被 (已安裝) postfix-2:2.10.1-9.el7.x86_64 需要
显示被postfix依赖,那就先把postfix卸载掉
$ rpm -e postfix
安装mysql-devel
这里一定不能直接使用yum安装,因为安装的还是mariadb的devel
下载mysql的yum源
https://dev.mysql.com/downloads/repo/yum/
上传
$ ll
-rw-r--r-- 1 root root 14064 12月 22 11:20 mysql80-community-release-el7-11.noarch.rpm
安装yum源
$ rpm -ivh mysql80-community-release-el7-11.noarch.rpm
警告:mysql80-community-release-el7-11.noarch.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql80-community-release-el7-11 ################################# [100%]
安装mysql-devel
$ yum makecache
$ yum install mysql-devel
已加载插件:fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Loading mirror speeds from cached hostfile
* base: mirrors.ustc.edu.cn
* development: mirrors.163.com
* epel: mirror.01link.hk
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 mysql-community-devel.x86_64.0.8.0.35-1.el7 将被 安装
--> 正在处理依赖关系 mysql-community-libs(x86-64) >= 8.0.11,它被软件包 mysql-community-devel-8.0.35-1.el7.x86_64 需要
--> 正在处理依赖关系 libmysqlclient.so.21()(64bit),它被软件包 mysql-community-devel-8.0.35-1.el7.x86_64 需要
--> 正在检查事务
---> 软件包 mysql-community-libs.x86_64.0.8.0.35-1.el7 将被 安装
--> 正在处理依赖关系 mysql-community-client-plugins = 8.0.35-1.el7,它被软件包 mysql-community-libs-8.0.35-1.el7.x86_64 需要
--> 正在处理依赖关系 mysql-community-common(x86-64) >= 8.0.11,它被软件包 mysql-community-libs-8.0.35-1.el7.x86_64 需要
--> 正在检查事务
---> 软件包 mysql-community-client-plugins.x86_64.0.8.0.35-1.el7 将被 安装
---> 软件包 mysql-community-common.x86_64.0.8.0.35-1.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
===========================================================================================================================================
Package 架构 版本 源 大小
===========================================================================================================================================
正在安装:
mysql-community-devel x86_64 8.0.35-1.el7 mysql80-community 1.9 M
为依赖而安装:
mysql-community-client-plugins x86_64 8.0.35-1.el7 mysql80-community 3.5 M
mysql-community-common x86_64 8.0.35-1.el7 mysql80-community 665 k
mysql-community-libs x86_64 8.0.35-1.el7 mysql80-community 1.5 M
事务概要
===========================================================================================================================================
安装 1 软件包 (+3 依赖软件包)
总下载量:7.5 M
安装大小:47 M
Is this ok [y/d/N]: y
Downloading packages:
警告:/var/cache/yum/x86_64/7/mysql80-community/packages/mysql-community-common-8.0.35-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
mysql-community-common-8.0.35-1.el7.x86_64.rpm 的公钥尚未安装
(1/4): mysql-community-common-8.0.35-1.el7.x86_64.rpm | 665 kB 00:00:01
(2/4): mysql-community-client-plugins-8.0.35-1.el7.x86_64.rpm | 3.5 MB 00:00:02
(3/4): mysql-community-devel-8.0.35-1.el7.x86_64.rpm | 1.9 MB 00:00:00
(4/4): mysql-community-libs-8.0.35-1.el7.x86_64.rpm | 1.5 MB 00:00:00
-------------------------------------------------------------------------------------------------------------------------------------------
总计 2.9 MB/s | 7.5 MB 00:00:02
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2023 检索密钥
导入 GPG key 0xA8D3785C:
用户ID : "MySQL Release Engineering <[email protected]>"
指纹 : bca4 3417 c3b4 85dd 128e c6d4 b7b3 b788 a8d3 785c
软件包 : mysql80-community-release-el7-11.noarch (installed)
来自 : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2023
是否继续?[y/N]:y
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022 检索密钥
导入 GPG key 0x3A79BD29:
用户ID : "MySQL Release Engineering <[email protected]>"
指纹 : 859b e8d7 c586 f538 430b 19c2 467b 942d 3a79 bd29
软件包 : mysql80-community-release-el7-11.noarch (installed)
来自 : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022
是否继续?[y/N]:y
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql 检索密钥
导入 GPG key 0x5072E1F5:
用户ID : "MySQL Release Engineering <[email protected]>"
指纹 : a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
软件包 : mysql80-community-release-el7-11.noarch (installed)
来自 : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
是否继续?[y/N]:y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 数据库已被非 yum 程序修改。
正在安装 : mysql-community-client-plugins-8.0.35-1.el7.x86_64 1/4
正在安装 : mysql-community-common-8.0.35-1.el7.x86_64 2/4
正在安装 : mysql-community-libs-8.0.35-1.el7.x86_64 3/4
正在安装 : mysql-community-devel-8.0.35-1.el7.x86_64 4/4
验证中 : mysql-community-libs-8.0.35-1.el7.x86_64 1/4
验证中 : mysql-community-devel-8.0.35-1.el7.x86_64 2/4
验证中 : mysql-community-common-8.0.35-1.el7.x86_64 3/4
验证中 : mysql-community-client-plugins-8.0.35-1.el7.x86_64 4/4
已安装:
mysql-community-devel.x86_64 0:8.0.35-1.el7
作为依赖被安装:
mysql-community-client-plugins.x86_64 0:8.0.35-1.el7 mysql-community-common.x86_64 0:8.0.35-1.el7
mysql-community-libs.x86_64 0:8.0.35-1.el7
完毕!
安装python的mysqlclient库
$ pip3 install mysqlclient
Looking in indexes: https://pypi.douban.com/simple/
Collecting mysqlclient
Using cached https://mirrors.cloud.tencent.com/pypi/packages/37/fb/d9a8f763c84f1e789c027af0ffc7dbf94c9a38db961484f253f0552cbb47/mysqlclient-2.2.1.tar.gz (89 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: mysqlclient
Building wheel for mysqlclient (pyproject.toml) ... done
Created wheel for mysqlclient: filename=mysqlclient-2.2.1-cp310-cp310-linux_x86_64.whl size=120350 sha256=0eb5250aa876b05d2ff7887678a3164cf1532576134c05cf8c6caf953cf37d75
Stored in directory: /root/.cache/pip/wheels/9e/96/6a/29eb845ede5d4ccb98934b1b776cde97c6d067ecc61e2c14ff
Successfully built mysqlclient
Installing collected packages: mysqlclient
Successfully installed mysqlclient-2.2.1
标签:8.0,x86,Centos,mysqlclient,community,64,mysql,el7,Python3
From: https://www.cnblogs.com/guangdelw/p/17921301.html