尝试安装 python mysqlclient 时获取 "cannot find -lmysqlclient"

Getting "cannot find -lmysqlclient" when trying to install python mysqlclient

我正在尝试使用 Percona 集群在 RHEL 的虚拟环境中安装 mysqlclient 模块 运行 a Mysql db.

每次退出时都出现这个错误

gcc -pthread -shared -Wl,-z,relro -g build/temp.linux-x86_64-3.6/MySQLdb/_mysql.o -L/usr/lib64 -L/usr/lib64

-lmysqlclient -lpthread -lz -lm -lrt -lssl -lcrypto -ldl -lpython3.6m -o build/lib.linux-x86_64-3.6/MySQLdb/_mysql.cpython-36m-x86_64-linux-gnu.so

/bin/ld: cannot find -lmysqlclient collect2: error: ld returned 1 exit status error: command 'gcc' failed with exit status 1

我相信我已经在此处安装了库:

$ ls /usr/lib64/mysql/

libmysqlclient.a

libmysqlclient_r.so.18.1.0

libmysqlclient.so.18.1.0

libperconaserverclient.a

libmysqlclient_r.a

libmysqlclient.so.18

libmysqlservices.a

libperconaserverclient_r.a

所以我不确定是什么问题

我必须像这样显式地将库路径传递给 gcc

sudo pip3 install mysqlclient --global-option=build_ext --global-option="-L/usr/lib64/mysql/"