Hey. I have an error when try to install mysqlclient to my Django project on Mac

Collecting mysqlclient Using cached mysqlclient-2.1.1.tar.gz (88 kB) Preparing metadata (setup.py) ... done Building wheels for collected packages: mysqlclient Building wheel for mysqlclient (setup.py) ... error error: subprocess-exited-with-error

× python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [43 lines of output] mysql_config --version ['8.0.32'] mysql_config --libs ['-L/usr/local/Cellar/mysql/8.0.32/lib', '-lmysqlclient', '-lz', '-L/usr/local/lib', '-lzstd', '-L/usr/local/opt/openssl@1.1/lib', '-lssl', '-lcrypto', '-lresolv'] mysql_config --cflags ['-I/usr/local/Cellar/mysql/8.0.32/include/mysql'] ext_options: library_dirs: ['/usr/local/Cellar/mysql/8.0.32/lib', '/usr/local/lib', '/usr/local/opt/openssl@1.1/lib'] libraries: ['mysqlclient', 'resolv'] extra_compile_args: ['-std=c99'] extra_link_args: [] include_dirs: ['/usr/local/Cellar/mysql/8.0.32/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-311 creating build/lib.macosx-10.9-universal2-cpython-311/MySQLdb copying MySQLdb/init.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb copying MySQLdb/_exceptions.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb copying MySQLdb/connections.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb copying MySQLdb/converters.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb copying MySQLdb/cursors.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb copying MySQLdb/release.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb copying MySQLdb/times.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb creating build/lib.macosx-10.9-universal2-cpython-311/MySQLdb/constants copying MySQLdb/constants/init.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb/constants copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb/constants copying MySQLdb/constants/CR.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb/constants copying MySQLdb/constants/ER.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb/constants copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb/constants copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb/constants warning: build_py: byte-compiling is disabled, skipping.

  running build_ext
  building 'MySQLdb._mysql' extension
  creating build/temp.macosx-10.9-universal2-cpython-311
  creating build/temp.macosx-10.9-universal2-cpython-311/MySQLdb
  clang -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -Dversion_info=(2,1,1,'final',0) -D__version__=2.1.1 -I/usr/local/Cellar/mysql/8.0.32/include/mysql -I/Users/pro/.local/share/virtualenvs/storefront-qb_mvtC8/include -I/Library/Frameworks/Python.framework/Versions/3.11/include/python3.11 -c MySQLdb/_mysql.c -o build/temp.macosx-10.9-universal2-cpython-311/MySQLdb/_mysql.o -std=c99
  xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
  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 Running setup.py clean for mysqlclient Failed to build mysqlclient Installing collected packages: mysqlclient Running setup.py install for mysqlclient ... error error: subprocess-exited-with-error

× Running setup.py install for mysqlclient did not run successfully. │ exit code: 1 ╰─> [45 lines of output] mysql_config --version ['8.0.32'] mysql_config --libs ['-L/usr/local/Cellar/mysql/8.0.32/lib', '-lmysqlclient', '-lz', '-L/usr/local/lib', '-lzstd', '-L/usr/local/opt/openssl@1.1/lib', '-lssl', '-lcrypto', '-lresolv'] mysql_config --cflags ['-I/usr/local/Cellar/mysql/8.0.32/include/mysql'] ext_options: library_dirs: ['/usr/local/Cellar/mysql/8.0.32/lib', '/usr/local/lib', '/usr/local/opt/openssl@1.1/lib'] libraries: ['mysqlclient', 'resolv'] extra_compile_args: ['-std=c99'] extra_link_args: [] include_dirs: ['/usr/local/Cellar/mysql/8.0.32/include/mysql'] extra_objects: [] define_macros: [('version_info', "(2,1,1,'final',0)"), ('version', '2.1.1')] running install /Users/pro/.local/share/virtualenvs/storefront-qb_mvtC8/lib/python3.11/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. warnings.warn( running build running build_py creating build creating build/lib.macosx-10.9-universal2-cpython-311 creating build/lib.macosx-10.9-universal2-cpython-311/MySQLdb copying MySQLdb/init.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb copying MySQLdb/_exceptions.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb copying MySQLdb/connections.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb copying MySQLdb/converters.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb copying MySQLdb/cursors.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb copying MySQLdb/release.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb copying MySQLdb/times.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb creating build/lib.macosx-10.9-universal2-cpython-311/MySQLdb/constants copying MySQLdb/constants/init.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb/constants copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb/constants copying MySQLdb/constants/CR.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb/constants copying MySQLdb/constants/ER.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb/constants copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb/constants copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb/constants warning: build_py: byte-compiling is disabled, skipping.

  running build_ext
  building 'MySQLdb._mysql' extension
  creating build/temp.macosx-10.9-universal2-cpython-311
  creating build/temp.macosx-10.9-universal2-cpython-311/MySQLdb
  clang -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -Dversion_info=(2,1,1,'final',0) -D__version__=2.1.1 -I/usr/local/Cellar/mysql/8.0.32/include/mysql -I/Users/pro/.local/share/virtualenvs/storefront-qb_mvtC8/include -I/Library/Frameworks/Python.framework/Versions/3.11/include/python3.11 -c MySQLdb/_mysql.c -o build/temp.macosx-10.9-universal2-cpython-311/MySQLdb/_mysql.o -std=c99
  xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
  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: legacy-install-failure

× Encountered error while trying to install package. ╰─> mysqlclient

note: This is an issue with the package mentioned above, not pip. hint: See above for output from the failure.

I try this Trouble installing MySQL client on Mac but its not helping to solve my issue.

I solved the problem by myself.

brew doctor

The problem was the xcode didn’t installed.

sudo xcode-select --install

Then run command:

pip install mysqlclient

Back to Top