首页 > 数据库 >Centos中安装Python3的mysqlclient库

Centos中安装Python3的mysqlclient库

时间:2023-12-22 11:56:32浏览次数:42  
标签:8.0 x86 Centos mysqlclient community 64 mysql el7 Python3

问题

系统是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

相关文章

  • centos系统安装docker和docker 使用
    基于centos系统安装docker,可以让你的开发更加专注下载阿里云的docker镜像wget-O/etc/yum.repos.d/docker-ce.repohttps://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo使用yum方式安装docker镜像yum-yinstalldocker-ce  到这里表......
  • CentOS7开启Firewalld防火墙日志记录获取被拦截的IP
    问题场景:在实际生产环境时使用该方法进行ES数据库白名单访问控制,但遇到业务侧反馈无法访问到ES数据库端口,需要加入到白名单,但业务侧用的IP业务侧无法准确给出于是通过如下面的方法解决这个问题1、firewalld的默认配置是不记录日志firewall-cmd--get-log-denied可以看到默认是off......
  • CentOS7下安装著名商业漏洞扫描工具Nexpose_6.6.156
    Nexpose简单介绍Nexpose是Rapid7出品,一款著名的、极佳的商业漏洞扫描工具。跟一般的扫描工具不同,Nexpose自身的功能非常强大,可以更新其漏洞数据库,以保证最新的漏洞被扫描到。漏洞扫描效率非常高,对于大型复杂网络,可优先考虑使用;可以给出哪些漏洞可以被MetasploitExploit,哪些漏......
  • centos7上源码安装postgresql 13.6
    1环境描述操作系统:Centos7.6postgresql:13.6安装方式:源码安装2创建用户#groupadd-g2000pgsql#useradd-u2000-gpgsqlpgsql3目录规划#mkdir-p/postgresql/{pgdata,archive,scripts,backup,pg13,soft,pg_log}#chown-Rpgsql:pgsql/postgresql#......
  • ​CentOS7一键脚本安装docker并创建ES集群(docker版本)
    CentOS7一键脚本安装docker并创建ES集群(docker版本)说明:1、脚本中修改了默认的docker的存储路径为/data/docker2、脚本中修改了docker默认的网段为10.112.0.1/243、脚本中拉取镜像并安装portainer容器Web管理工具#!/bin/bashsed-i's/enforcing/disabled/g'/etc/selinux/confi......
  • Mac os安装python3.10
    当你使用Homebrew安装新版本的Python后,python命令通常会链接到新版本。但有时候,系统会维持对默认Python版本的引用,这可能导致python命令仍然指向旧版本。你可以尝试以下步骤来确保正确的Python版本被使用:确认Python3.10是否成功安装:brewinfopython@......
  • centos 6.10 安装 qtCreator6.0.2
    centos6.10安装qtCreator6.0.2在centos6.10上源码编译安装qtCreator6.0.2下载地址下载后解压然后执行下面命令cdqt-creator-opensource-src-6.0.2mkdirbuild&&cdbuildcmake..makeset(CMAKE_PREFIX_PATH/home/fla/soft/qt5.15.11/lib/cmake/Qt5)SET(CMAKE......
  • centos7 下安装 moodle历史命令(未能包含vim 修改配置文件)
    1init02cd"/data/webapps/moodle"3cd/data/webapps/4ls5ll6cdmoodle/7ls8ll9vimlib/outputrenderers.php10ll11cd../12ll13chmod-R0777./moodle/14ll15......
  • Docker Alpine Linux 安装 Python3
      参考文档:DockerAlpineLinux安装Pytho1、DockerfileDockerfile文件一般包含基础镜像信息、维护者信息、镜像操作指令和容器启动时执行指令,’#’为Dockerfile中的注释。参考文件::Docker构建自定义镜像和Dockerfile文件2、直接安装 通过Dockerfile文件构建镜像时,直......
  • 安装CentOS Vault系统踩过的坑
    CentOSVault简介一、CentOSVault介绍CentOSVault是CentOS发布的一个yum镜像,存放CentOS历史版本的软件包和安装介质。CentOSVault的使命是为已经部署了CentOS系统的用户提供历史版本的安全更新、补丁和其他必要的软件包,以确保其系统的安全和稳定性。CentOSVault的官方网......