6

我尝试了为 mysqlclient 错误编写的常见解决方案

  • 第一次尝试:brew install mysql-connector-c
  • 第二次尝试: LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysqlclient
  • 第三次尝试:brew install zstd

mysql服务器运行良好。但是错误没有得到修复..

我开始clang linker errorlibrary 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
4

1 回答 1

6

就我而言,我没有 sudo 访问权限,因此为我的用户安装了 brew 检查您的 brew 是否不在默认位置 ,请执行此操作以检查您安装 brew的位置

brew --prefix
output: Users/helloWorld/homebrew

使用上面的输出来设置 ld 标志和 cpp 标志,例如我没有找到 ssl 和 zstd 库,所以这就是我所做的:

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" 

然后进行 pip 安装

pip3 install mysqlclient
于 2021-06-22T04:39:30.027 回答