【解决】Linux环境中mysqlclient安装失败问题
问题描述
在Linux系统下安装myslclient报异常。系统为Centos 8
使用 pip install mysqlclient 报出下面的异常
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [30 lines of output]
/bin/sh: pkg-config: command not found
/bin/sh: pkg-config: command not found
/bin/sh: pkg-config: command not found
Trying pkg-config --exists mysqlclient
Command 'pkg-config --exists mysqlclient' returned non-zero exit status 127.
Trying pkg-config --exists mariadb
Command 'pkg-config --exists mariadb' returned non-zero exit status 127.
起初以为是 pk-config 的命令没有安装, 所以采用下面命令 安装了 pkgconfig
sudo yum install pkgconfig
然后进行 pip install mysqlclient 发现错误依旧。最终才发现,关键在报错信息的最后,有提示,需要手动指定mysqlclient_cflags
和mysqlclient_ldflags