pythonmysqlpippercona-xtradb-cluster

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


I'm trying to install the mysqlclient module in a virtual environment on RHEL with Percona clustering running a Mysql db.

Each time it exits with this error

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

I believe I have the library installed here:

$ 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

So I'm not sure what the problem is


Solution

  • I had to explicitly pass the library path to gcc like this

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