I'm encountering an issue while trying to install the mysqlclient package on Python 3.12.0. The build process fails with a clang error. I've included the relevant error output below.
Note: I have turned to use PySQL and it rightly worked. But I am still want to dig into and fix the below issue on my project.
- Environment Details:
- Python version:
3.12.0 - Django version:
5.0.1
- Additional bash's info:
Collecting mysqlclient
Using cached mysqlclient-2.2.1.tar.gz (89 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... 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
╰─> [41 lines of output]
# Options for building extension module:
extra_compile_args: ['-I/opt/homebrew/Cellar/mysql-client/8.2.0/include/mysql', '-std=c99']
extra_link_args: ['-L/opt/homebrew/Cellar/mysql-client/8.2.0/lib', '-lmysqlclient']
define_macros: [('version_info', (2, 2, 1, 'final', 0)), ('__version__', '2.2.1')]
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.9-universal2-cpython-312
creating build/lib.macosx-10.9-universal2-cpython-312/MySQLdb
copying src/MySQLdb/release.py -> build/lib.macosx-10.9-universal2-cpython-312/MySQLdb
copying src/MySQLdb/cursors.py -> build/lib.macosx-10.9-universal2-cpython-312/MySQLdb
copying src/MySQLdb/connections.py -> build/lib.macosx-10.9-universal2-cpython-312/MySQLdb
copying src/MySQLdb/__init__.py -> build/lib.macosx-10.9-universal2-cpython-312/MySQLdb
copying src/MySQLdb/times.py -> build/lib.macosx-10.9-universal2-cpython-312/MySQLdb
copying src/MySQLdb/converters.py -> build/lib.macosx-10.9-universal2-cpython-312/MySQLdb
copying src/MySQLdb/_exceptions.py -> build/lib.macosx-10.9-universal2-cpython-312/MySQLdb
creating build/lib.macosx-10.9-universal2-cpython-312/MySQLdb/constants
copying src/MySQLdb/constants/FLAG.py -> build/lib.macosx-10.9-universal2-cpython-312/MySQLdb/constants
copying src/MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.9-universal2-cpython-312/MySQLdb/constants
copying src/MySQLdb/constants/__init__.py -> build/lib.macosx-10.9-universal2-cpython-312/MySQLdb/constants
copying src/MySQLdb/constants/ER.py -> build/lib.macosx-10.9-universal2-cpython-312/MySQLdb/constants
copying src/MySQLdb/constants/CR.py -> build/lib.macosx-10.9-universal2-cpython-312/MySQLdb/constants
copying src/MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.9-universal2-cpython-312/MySQLdb/constants
running egg_info
writing src/mysqlclient.egg-info/PKG-INFO
writing dependency_links to src/mysqlclient.egg-info/dependency_links.txt
writing top-level names to src/mysqlclient.egg-info/top_level.txt
reading manifest file 'src/mysqlclient.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
adding license file 'LICENSE'
writing manifest file 'src/mysqlclient.egg-info/SOURCES.txt'
copying src/MySQLdb/_mysql.c -> build/lib.macosx-10.9-universal2-cpython-312/MySQLdb
running build_ext
building 'MySQLdb._mysql' extension
creating build/temp.macosx-10.9-universal2-cpython-312
creating build/temp.macosx-10.9-universal2-cpython-312/src
creating build/temp.macosx-10.9-universal2-cpython-312/src/MySQLdb
clang -fno-strict-overflow -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -O3 -Wall -arch arm64 -arch x86_64 -g "-Dversion_info=(2, 2, 1, 'final', 0)" -D__version__=2.2.1 -I/Users/fuwhis/Desktop/cloudsky/django-blog-example/env/include -I/Library/Frameworks/Python.framework/Versions/3.12/include/python3.12 -c src/MySQLdb/_mysql.c -o build/temp.macosx-10.9-universal2-cpython-312/src/MySQLdb/_mysql.o -I/opt/homebrew/Cellar/mysql-client/8.2.0/include/mysql -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
Failed to build mysqlclient
ERROR: Could not build wheels for mysqlclient, which is required to install pyproject.toml-based projects
See the installation guide for macOS (Homebrew) on PyPi:
Install MySQL and mysqlclient:
If you don't want to install MySQL server, you can use mysql-client instead: