Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error when install mysqlclient using pip to MacOS Bigsur

I've tried common solutions written for mysqlclient error

  • 1st try: brew install mysql-connector-c
  • 2nd try: LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysqlclient
  • 3rd try: brew install zstd

And mysql server is well-running. But the error is not being fixed..

I am getting clang linker error saying library not found for -lzstd

    clang -bundle -undefined dynamic_lookup -L/usr/local/opt/readline/lib -L/usr/local/opt/readline/lib -L/Users/user/.asdf/installs/python/3.7.10/lib -L/usr/local/opt/llvm/lib -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/readline/lib -L/Users/user/.asdf/installs/python/3.7.10/lib -L/usr/local/opt/llvm/lib -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -L/usr/local/opt/llvm/lib -I/usr/local/opt/llvm/include build/temp.macosx-11.2-x86_64-3.7/MySQLdb/_mysql.o -L/usr/local/Cellar/mysql/8.0.25_1/lib -lmysqlclient -lzstd -lresolv -o build/lib.macosx-11.2-x86_64-3.7/MySQLdb/_mysql.cpython-37m-darwin.so
ld: library not found for -lzstd
clang-12: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1
like image 709
victory Avatar asked May 31 '21 02:05

victory


People also ask

Does Mysqlclient support Python 3?

This project is a fork of MySQLdb1. This project adds Python 3 support and fixed many bugs.

Does Django need Mysqlclient?

You use pip to install it directly: pip install mysqlclient. Note that you don't need this to try Django; nor do you need Apache. Python and Django is already an "integrated development environment" since Python includes sqlite3, and Django includes a development server.


1 Answers

In my case I did not had the sudo access so installed brew for my user Check if your brew is not in default location do this to check where you have installed brew

brew --prefix
output: Users/helloWorld/homebrew

use the output of above to set the ld flags and cpp flags for example for me ssl and zstd libs were not found so this is what i did:

export LDFLAGS="-L/Users/helloWorld/homebrew/lib -L/Users/helloWorld/homebrew/opt/openssl/lib"

export CPPFLAGS="-I/Users/helloWorld/homebrew/include -I/Users/helloWorld/homebrew/opt/openssl/include" 

and then do the pip install

pip3 install mysqlclient
like image 154
Rahul Rai Avatar answered Sep 29 '22 13:09

Rahul Rai