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
asked May 31, 2021 at 2:21
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
answered Jun 22, 2021 at 4:39
6
Tôi đã cài đặt rồi
- Python 2.7.13
- Django 1.11
- MySQL 5.7.17
Tôi muốn sử dụng MySQL với Django, nhưng sau khi cài đặt trình kết nối mysql, tôi đã cố gắng cài đặt mysqlclient cho Python $ pip install mysqlclient
, nhưng tôi gặp sự cố này:
Collecting mysqlclient
Using cached mysqlclient-1.3.10.tar.gz
Complete output from command python setup.py egg_info:
Traceback [most recent call last]:
File "", line 1, in
File "/private/var/folders/y_/c31n_1v12v169zfv829p_v_80000gn/T/pip-build-f51KhW/mysqlclient/setup.py", line 17, in
metadata, options = get_config[]
File "setup_posix.py", line 54, in get_config
libraries = [dequote[i[2:]] for i in libs if i.startswith['-l']]
File "setup_posix.py", line 12, in dequote
if s[0] in "\"'" and s[0] == s[-1]:
IndexError: string index out of range
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/y_/c31n_1v12v169zfv829p_v_80000gn/T/pip-build-f51KhW/mysqlclient/
- python
- mysql
- django
- macos
21 hữu ích 1 bình luận 33k xem chia sẻ
answer
48
Tôi cần những
thứ sau để xây dựng / cài đặt mysqlclient
brew install mysql-client
# mysql-client is not on the `PATH` by default
export PATH="/usr/local/opt/mysql-client/bin:$PATH"
# openssl is not on the link path by default
export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/opt/openssl/lib/"
Sau đó, tôi có thể pip wheel mysqlclient
/ pip install mysqlclient
thành công
48 hữu ích 0 bình luận chia sẻ
answer
21
Tôi cũng gặp phải vấn đề này , dưới đây là bước của tôi :
1.brew install mysql-connector-c
2.pip install mysqlclient
và sau đó gặp lỗi này, tôi đã Truy xuất mã nguồn , nhưng giải quyết được lỗi này thì lỗi khác lại xảy ra.
vì vậy tôi đã thay đổi cách cài đặt mysqlclient, chỉ cần:
1.brew install mysql
2.pip install mysqlclient
điều này đã làm việc cho tôi, không có bất kỳ lỗi nào xảy ra.
21 hữu ích 1 bình luận chia sẻ
answer
12
Cài đặt mysql-client
thay vì cài đặt mysql
nếu bạn không định có mysql
trong máy tính của mình
brew install mysql-client
echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
pip install mysqlclient
xuất LDFLAGS = "- L / usr / local / opt / openssl / lib"
xuất CPPFLAGS = "- I / usr / local / opt / openssl / include"
12 hữu ích 2 bình luận chia sẻ
answer
11
brew install/upgrade/reinstall mysql
brew install mysql-client
export PATH="/usr/local/opt/openssl/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
pip install mysqlclient
works perfectly
11 hữu ích 3 bình luận chia sẻ
answer
7
Đối với Mac: trước tiên hãy tải xuống Xcode từ App Store và MySqlWorkbench từ //dev.mysql.com/downloads/workbench/
Chạy các lệnh sau trong thiết bị đầu cuối,
$ brew install mysql
$ export PATH=$PATH:/Applications/MySQLWorkbench.app/Contents/MacOS
$ xcode-select --install
$ pip install mysqlclient
7 hữu ích 2 bình luận chia sẻ
answer
3
Cài đặt mysql bằng cách sử dụng brew và thêm nó vào đường dẫn:
$ brew install mysql
$ export PATH=/usr/local/mysql/bin:$PATH
$ sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/lib/libmysqlclient.18.dylib
$ pip install mysqlclient
3 hữu ích 0 bình luận chia sẻ