Pipenv install mysqlclient error on mac

pipenv install mysqlclient

Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.
Installing mysqlclient…
Error: An error occurred while installing mysqlclient!
Error text: Collecting mysqlclient
Using cached mysqlclient-2.0.3.tar.gz (88 kB)
Building wheels for collected packages: mysqlclient
Building wheel for mysqlclient (setup.py): started
Building wheel for mysqlclient (setup.py): finished with status ‘error’
Running setup.py clean for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient: started
Running setup.py install for mysqlclient: finished with status ‘error’

ERROR: Command errored out with exit status 1:
command: /Users/amanbay/.local/share/virtualenvs/django-aiKsYuxq/bin/python -u -c ‘import io, os, sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/private/var/folders/vj/120rvkm10g9g0_6cmldw2_6h0000gn/T/pip-install-ebla2bvs/mysqlclient_c37fdc9770a648de9508f3cb3d9b0f51/setup.py’"’"’; file=’"’"’/private/var/folders/vj/120rvkm10g9g0_6cmldw2_6h0000gn/T/pip-install-ebla2bvs/mysqlclient_c37fdc9770a648de9508f3cb3d9b0f51/setup.py’"’"’;f = getattr(tokenize, ‘"’"‘open’"’"’, open)(file) if os.path.exists(file) else io.StringIO(’"’"‘from setuptools import setup; setup()’"’"’);code = f.read().replace(’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’ bdist_wheel -d /private/var/folders/vj/120rvkm10g9g0_6cmldw2_6h0000gn/T/pip-wheel-3_2hc9b6
cwd: /private/var/folders/vj/120rvkm10g9g0_6cmldw2_6h0000gn/T/pip-install-ebla2bvs/mysqlclient_c37fdc9770a648de9508f3cb3d9b0f51/
Complete output (43 lines):
mysql_config --version
[‘8.0.25’]
mysql_config --libs
[’-L/usr/local/opt/mysql-client/lib’, ‘-lmysqlclient’, ‘-lz’, ‘-lzstd’, ‘-lssl’, ‘-lcrypto’, ‘-lresolv’]
mysql_config --cflags
[’-I/usr/local/opt/mysql-client/include/mysql’]
ext_options:
library_dirs: [’/usr/local/opt/mysql-client/lib’]
libraries: [‘mysqlclient’, ‘zstd’, ‘resolv’]
extra_compile_args: [’-std=c99’]
extra_link_args: []
include_dirs: [’/usr/local/opt/mysql-client/include/mysql’]
extra_objects: []
define_macros: [(‘version_info’, “(2,0,3,‘final’,0)”), (‘version’, ‘2.0.3’)]
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-11-x86_64-3.9
creating build/lib.macosx-11-x86_64-3.9/MySQLdb
copying MySQLdb/init.py → build/lib.macosx-11-x86_64-3.9/MySQLdb
copying MySQLdb/_exceptions.py → build/lib.macosx-11-x86_64-3.9/MySQLdb
copying MySQLdb/connections.py → build/lib.macosx-11-x86_64-3.9/MySQLdb
copying MySQLdb/converters.py → build/lib.macosx-11-x86_64-3.9/MySQLdb
copying MySQLdb/cursors.py → build/lib.macosx-11-x86_64-3.9/MySQLdb
copying MySQLdb/release.py → build/lib.macosx-11-x86_64-3.9/MySQLdb
copying MySQLdb/times.py → build/lib.macosx-11-x86_64-3.9/MySQLdb
creating build/lib.macosx-11-x86_64-3.9/MySQLdb/constants
copying MySQLdb/constants/init.py → build/lib.macosx-11-x86_64-3.9/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py → build/lib.macosx-11-x86_64-3.9/MySQLdb/constants
copying MySQLdb/constants/CR.py → build/lib.macosx-11-x86_64-3.9/MySQLdb/constants
copying MySQLdb/constants/ER.py → build/lib.macosx-11-x86_64-3.9/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py → build/lib.macosx-11-x86_64-3.9/MySQLdb/constants
copying MySQLdb/constants/FLAG.py → build/lib.macosx-11-x86_64-3.9/MySQLdb/constants
warning: build_py: byte-compiling is disabled, skipping.

running build_ext
building 'MySQLdb.mysql’ extension
creating build/temp.macosx-11-x86_64-3.9
creating build/temp.macosx-11-x86_64-3.9/MySQLdb
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -Dversion_info=(2,0,3,‘final’,0) -D__version
_=2.0.3 -I/usr/local/opt/mysql-client/include/mysql -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/sqlite/include -I/Users/amanbay/.local/share/virtualenvs/django-aiKsYuxq/include -I/usr/local/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c MySQLdb/_mysql.c -o build/temp.macosx-11-x86_64-3.9/MySQLdb/_mysql.o -std=c99
clang: error: invalid version number in ‘MACOSX_DEPLOYMENT_TARGET=11’
error: command ‘/usr/bin/clang’ failed with exit code 1

ERROR: Failed building wheel for mysqlclient
ERROR: Command errored out with exit status 1:
command: /Users/amanbay/.local/share/virtualenvs/django-aiKsYuxq/bin/python -u -c ‘import io, os, sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/private/var/folders/vj/120rvkm10g9g0_6cmldw2_6h0000gn/T/pip-install-ebla2bvs/mysqlclient_c37fdc9770a648de9508f3cb3d9b0f51/setup.py’"’"’; file=’"’"’/private/var/folders/vj/120rvkm10g9g0_6cmldw2_6h0000gn/T/pip-install-ebla2bvs/mysqlclient_c37fdc9770a648de9508f3cb3d9b0f51/setup.py’"’"’;f = getattr(tokenize, ‘"’"‘open’"’"’, open)(file) if os.path.exists(file) else io.StringIO(’"’"‘from setuptools import setup; setup()’"’"’);code = f.read().replace(’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’ install --record /private/var/folders/vj/120rvkm10g9g0_6cmldw2_6h0000gn/T/pip-record-rb7_hnf4/install-record.txt --single-version-externally-managed --compile --install-headers /Users/amanbay/.local/share/virtualenvs/django-aiKsYuxq/include/site/python3.9/mysqlclient
cwd: /private/var/folders/vj/120rvkm10g9g0_6cmldw2_6h0000gn/T/pip-install-ebla2bvs/mysqlclient_c37fdc9770a648de9508f3cb3d9b0f51/
Complete output (43 lines):
mysql_config --version
[‘8.0.25’]
mysql_config --libs
[’-L/usr/local/opt/mysql-client/lib’, ‘-lmysqlclient’, ‘-lz’, ‘-lzstd’, ‘-lssl’, ‘-lcrypto’, ‘-lresolv’]
mysql_config --cflags
[’-I/usr/local/opt/mysql-client/include/mysql’]
ext_options:
library_dirs: [’/usr/local/opt/mysql-client/lib’]
libraries: [‘mysqlclient’, ‘zstd’, ‘resolv’]
extra_compile_args: [’-std=c99’]
extra_link_args: []
include_dirs: [’/usr/local/opt/mysql-client/include/mysql’]
extra_objects: []
define_macros: [(‘version_info’, “(2,0,3,‘final’,0)”), (‘version’, ‘2.0.3’)]
running install
running build
running build_py
creating build
creating build/lib.macosx-11-x86_64-3.9
creating build/lib.macosx-11-x86_64-3.9/MySQLdb
copying MySQLdb/init.py → build/lib.macosx-11-x86_64-3.9/MySQLdb
copying MySQLdb/_exceptions.py → build/lib.macosx-11-x86_64-3.9/MySQLdb
copying MySQLdb/connections.py → build/lib.macosx-11-x86_64-3.9/MySQLdb
copying MySQLdb/converters.py → build/lib.macosx-11-x86_64-3.9/MySQLdb
copying MySQLdb/cursors.py → build/lib.macosx-11-x86_64-3.9/MySQLdb
copying MySQLdb/release.py → build/lib.macosx-11-x86_64-3.9/MySQLdb
copying MySQLdb/times.py → build/lib.macosx-11-x86_64-3.9/MySQLdb
creating build/lib.macosx-11-x86_64-3.9/MySQLdb/constants
copying MySQLdb/constants/init.py → build/lib.macosx-11-x86_64-3.9/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py → build/lib.macosx-11-x86_64-3.9/MySQLdb/constants
copying MySQLdb/constants/CR.py → build/lib.macosx-11-x86_64-3.9/MySQLdb/constants
copying MySQLdb/constants/ER.py → build/lib.macosx-11-x86_64-3.9/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py → build/lib.macosx-11-x86_64-3.9/MySQLdb/constants
copying MySQLdb/constants/FLAG.py → build/lib.macosx-11-x86_64-3.9/MySQLdb/constants
warning: build_py: byte-compiling is disabled, skipping.

running build_ext
building 'MySQLdb._mysql' extension
creating build/temp.macosx-11-x86_64-3.9
creating build/temp.macosx-11-x86_64-3.9/MySQLdb
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -Dversion_info=(2,0,3,'final',0) -D__version__=2.0.3 -I/usr/local/opt/mysql-client/include/mysql -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/sqlite/include -I/Users/amanbay/.local/share/virtualenvs/django-aiKsYuxq/include -I/usr/local/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c MySQLdb/_mysql.c -o build/temp.macosx-11-x86_64-3.9/MySQLdb/_mysql.o -std=c99
clang: error: invalid version number in 'MACOSX_DEPLOYMENT_TARGET=11'
error: command '/usr/bin/clang' failed with exit code 1
----------------------------------------

ERROR: Command errored out with exit status 1: /Users/amanbay/.local/share/virtualenvs/django-aiKsYuxq/bin/python -u -c ‘import io, os, sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/private/var/folders/vj/120rvkm10g9g0_6cmldw2_6h0000gn/T/pip-install-ebla2bvs/mysqlclient_c37fdc9770a648de9508f3cb3d9b0f51/setup.py’"’"’; file=’"’"’/private/var/folders/vj/120rvkm10g9g0_6cmldw2_6h0000gn/T/pip-install-ebla2bvs/mysqlclient_c37fdc9770a648de9508f3cb3d9b0f51/setup.py’"’"’;f = getattr(tokenize, ‘"’"‘open’"’"’, open)(file) if os.path.exists(file) else io.StringIO(’"’"‘from setuptools import setup; setup()’"’"’);code = f.read().replace(’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’ install --record /private/var/folders/vj/120rvkm10g9g0_6cmldw2_6h0000gn/T/pip-record-rb7_hnf4/install-record.txt --single-version-externally-managed --compile --install-headers /Users/amanbay/.local/share/virtualenvs/django-aiKsYuxq/include/site/python3.9/mysqlclient Check the logs for full command output.

✘ Installation Failed

I solived the problem myself.

Solution:

brew doctor

And fix the problems first .

In my keys the problem was the xcode didn’t installed.

sudo xcode-select --install

hello amanm Do you have any Idea how to fix it on window, I install it by “pip insall mysqlclient” but not able to import it in a python file.

Also tried in pipenv. but not worked.

Can you send the error

how do you screenshot to attach to comments? how often is the forum updated?

I am super excited that I just solved this issue. In my process, I uninstall the python 3.9 which download by website. Then, use “brew” to install python 3.9 then rebuild a virtual env. Now, it works!