linux安装 mysqlclient报错问题

错误代码如下

Collecting mysqlclient==2.2.4
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/79/33/996dc0ba3f03e2399adc91a7de1f61cb14b57ebdb4cc6eca8a78723043cb/mysqlclient-2.2.4.tar.gz (90 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 "/www/wwwroot/PySoft/ameienv/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()

原因是因为
MariaDB数据库是centos操作系统中自带的,但是!!! MySQL 和 MariaDB 是不同的数据库系统,它们各自提供的开发库有文件冲突,不能同时安装。索性手动安装!

  1. 卸载MariaDB库
# 查看
 rpm -qa | grep mariadb
 mariadb-libs-1:5.5.68-1.el7.x86_64
 mariadb-devel-1:5.5.68-1.el7.x86_64
#卸载
rpm -e mariadb-devel-1:5.5.68-1.el7.x86_64
rpm -e mariadb-libs-1:5.5.68-1.el7.x86_64

卸载之后,不可用yum,也不可pip安装 mysql-devel,因为yum或者pip安装mysql-devel ,会比较扯,使用yum安装的时候 ,mariadb会再次被安装
在这里插入图片描述

  1. 官网下载对应的系统,mysql版本,安装mysql-devel
    我的mysql版本,以及服务器系统,如图
    可单独下载,也可下载压缩包
    在这里插入图片描述

下载之后传到服务器上,解压

tar -xvf mysql-8.0.24-1.el7.x86_64.rpm-bundle.tar

一定要按顺序安装,因为它们互相依赖

rpm -ivh mysql-community-common-8.0.24-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.24-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-8.0.24-1.el7.x86_64.rpm
rpm -ivh mysql-community-devel-8.0.24-1.el7.x86_64.rpm

如过安装过程中报错,如下图
在这里插入图片描述
使用强制安装

rpm -ivh mysql-community-libs-8.0.24-1.el7.x86_64.rpm --nodeps --force

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
查看
在这里插入图片描述

然后用pip安装 mysqlclient

#我用的是2.2.4版本,按需选择版本
pip install mysqlclient==2.2.4

在这里插入图片描述
至此解决问题!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值