0

`pip install mysqlclient Collecting mysqlclient Using cached mysqlclient-2.1.1.tar.gz (88 kB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Building wheels for collected packages: mysqlclient Building wheel for mysqlclient (pyproject.toml) ... error error: subprocess-exited-with-error

× Building wheel for mysqlclient (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [43 lines of output] mysql_config --version ['8.0.33'] mysql_config --libs ['-L/opt/homebrew/Cellar/mysql/8.0.33/lib', '-lmysqlclient', '-lzlib', '-lzstd', '-L/opt/homebrew/opt/[email protected]/lib', '-lssl', '-lcrypto', '-lresolv'] mysql_config --cflags ['-I/opt/homebrew/Cellar/mysql/8.0.33/include/mysql'] ext_options: library_dirs: ['/opt/homebrew/Cellar/mysql/8.0.33/lib', '/opt/homebrew/opt/[email protected]/lib'] libraries: ['mysqlclient', 'zlib', 'resolv'] extra_compile_args: ['-std=c99'] extra_link_args: [] include_dirs: ['/opt/homebrew/Cellar/mysql/8.0.33/include/mysql'] extra_objects: [] define_macros: [('version_info', "(2,1,1,'final',0)"), ('version', '2.1.1')] running bdist_wheel running build running build_py creating build creating build/lib.macosx-10.9-universal2-cpython-310 creating build/lib.macosx-10.9-universal2-cpython-310/MySQLdb copying MySQLdb/init.py -> build/lib.macosx-10.9-universal2-cpython-310/MySQLdb copying MySQLdb/exceptions.py -> build/lib.macosx-10.9-universal2-cpython-310/MySQLdb copying MySQLdb/connections.py -> build/lib.macosx-10.9-universal2-cpython-310/MySQLdb copying MySQLdb/converters.py -> build/lib.macosx-10.9-universal2-cpython-310/MySQLdb copying MySQLdb/cursors.py -> build/lib.macosx-10.9-universal2-cpython-310/MySQLdb copying MySQLdb/release.py -> build/lib.macosx-10.9-universal2-cpython-310/MySQLdb copying MySQLdb/times.py -> build/lib.macosx-10.9-universal2-cpython-310/MySQLdb creating build/lib.macosx-10.9-universal2-cpython-310/MySQLdb/constants copying MySQLdb/constants/init.py -> build/lib.macosx-10.9-universal2-cpython-310/MySQLdb/constants copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.9-universal2-cpython-310/MySQLdb/constants copying MySQLdb/constants/CR.py -> build/lib.macosx-10.9-universal2-cpython-310/MySQLdb/constants copying MySQLdb/constants/ER.py -> build/lib.macosx-10.9-universal2-cpython-310/MySQLdb/constants copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.9-universal2-cpython-310/MySQLdb/constants copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.9-universal2-cpython-310/MySQLdb/constants running build_ext building 'MySQLdb.mysql' extension creating build/temp.macosx-10.9-universal2-cpython-310 creating build/temp.macosx-10.9-universal2-cpython-310/MySQLdb clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -I/opt/homebrew/opt/openssl@3/include -Dversion_info=(2,1,1,'final',0) -D__version=2.1.1 -I/opt/homebrew/Cellar/mysql/8.0.33/include/mysql -I/Library/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c MySQLdb/_mysql.c -o build/temp.macosx-10.9-universal2-cpython-310/MySQLdb/_mysql.o -std=c99 clang -bundle -undefined dynamic_lookup -arch arm64 -arch x86_64 -g -L/opt/homebrew/opt/openssl@3/lib -I/opt/homebrew/opt/openssl@3/include build/temp.macosx-10.9-universal2-cpython-310/MySQLdb/_mysql.o -L/opt/homebrew/Cellar/mysql/8.0.33/lib -L/opt/homebrew/opt/[email protected]/lib -lmysqlclient -lzlib -lresolv -o build/lib.macosx-10.9-universal2-cpython-310/MySQLdb/_mysql.cpython-310-darwin.so ld: library not found for -lzlib clang: error: linker command failed with exit code 1 (use -v to see invocation) error: command '/usr/bin/clang' failed with exit code 1 [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for mysqlclient Failed to build mysqlclient ERROR: Could not build wheels for mysqlclient, which is required to install pyproject.toml-based projects`

I was following guide from official repo https://github.com/PyMySQL/mysqlclient:

macOS (Homebrew) Install MySQL and mysqlclient:

Assume you are activating Python 3 venv

$ brew install mysql $ pip install mysqlclient

Instead of venv, i am using Poetry. I have tried also without any virtualenv and i have same issue. Mysql is installed correctly and i can run it.

1 Answer 1

2

This issue was raised yesterday in the mysqlclient repository on GitHub.

GitHub user @methane provided a workaround by slightly modifying some environment variables using the pkg-config utility before installing that seem to have worked for others in a similar execution environment:

export MYSQLCLIENT_LDFLAGS=$(pkg-config --libs mysqlclient)
export MYSQLCLIENT_CFLAGS=$(pkg-config --cflags mysqlclient)
pip install mysqlclient
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.