Skip to content

Can't install mysqlclient on Mac M1 Big Sur (11.2.2) #497

@m-ketan

Description

@m-ketan

Python: 3.9.5
mysql: 8.0.25

Trying to install mysqlclient for setting up connection with django but failing with the below output:

Collecting mysqlclient
  Using cached mysqlclient-2.0.3.tar.gz (88 kB)
Using legacy 'setup.py install' for mysqlclient, since package 'wheel' is not installed.
Installing collected packages: mysqlclient
    Running setup.py install for mysqlclient ... error
    ERROR: Command errored out with exit status 1:
     command: /Users/mketan/Documents/diit/diit_env/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/qm/kp4ls0ds5q7gh4rtfqy4xxrr0000gn/T/pip-install-fbu018c0/mysqlclient_64e4fa21b76648ff84f8c751e242384d/setup.py'"'"'; __file__='"'"'/private/var/folders/qm/kp4ls0ds5q7gh4rtfqy4xxrr0000gn/T/pip-install-fbu018c0/mysqlclient_64e4fa21b76648ff84f8c751e242384d/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/qm/kp4ls0ds5q7gh4rtfqy4xxrr0000gn/T/pip-record-3wl14yep/install-record.txt --single-version-externally-managed --compile --install-headers /Users/b0223621/Documents/diit/diit_env/include/site/python3.9/mysqlclient
         cwd: /private/var/folders/qm/kp4ls0ds5q7gh4rtfqy4xxrr0000gn/T/pip-install-fbu018c0/mysqlclient_64e4fa21b76648ff84f8c751e242384d/
    Complete output (43 lines):
    mysql_config --version
    ['8.0.25']
    mysql_config --libs
    ['-L/opt/homebrew/Cellar/mysql/8.0.25_1/lib', '-lmysqlclient', '-lz', '-lzstd', '-lssl', '-lcrypto', '-lresolv']
    mysql_config --cflags
    ['-I/opt/homebrew/Cellar/mysql/8.0.25_1/include/mysql']
    ext_options:
      library_dirs: ['/opt/homebrew/Cellar/mysql/8.0.25_1/lib']
      libraries: ['mysqlclient', 'zstd', 'resolv']
      extra_compile_args: ['-std=c99']
      extra_link_args: []
      include_dirs: ['/opt/homebrew/Cellar/mysql/8.0.25_1/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-10.9-universal2-3.9
    creating build/lib.macosx-10.9-universal2-3.9/MySQLdb
    copying MySQLdb/__init__.py -> build/lib.macosx-10.9-universal2-3.9/MySQLdb
    copying MySQLdb/_exceptions.py -> build/lib.macosx-10.9-universal2-3.9/MySQLdb
    copying MySQLdb/connections.py -> build/lib.macosx-10.9-universal2-3.9/MySQLdb
    copying MySQLdb/converters.py -> build/lib.macosx-10.9-universal2-3.9/MySQLdb
    copying MySQLdb/cursors.py -> build/lib.macosx-10.9-universal2-3.9/MySQLdb
    copying MySQLdb/release.py -> build/lib.macosx-10.9-universal2-3.9/MySQLdb
    copying MySQLdb/times.py -> build/lib.macosx-10.9-universal2-3.9/MySQLdb
    creating build/lib.macosx-10.9-universal2-3.9/MySQLdb/constants
    copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.9-universal2-3.9/MySQLdb/constants
    copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.9-universal2-3.9/MySQLdb/constants
    copying MySQLdb/constants/CR.py -> build/lib.macosx-10.9-universal2-3.9/MySQLdb/constants
    copying MySQLdb/constants/ER.py -> build/lib.macosx-10.9-universal2-3.9/MySQLdb/constants
    copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.9-universal2-3.9/MySQLdb/constants
    copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.9-universal2-3.9/MySQLdb/constants
    running build_ext
    building 'MySQLdb._mysql' extension
    creating build/temp.macosx-10.9-universal2-3.9
    creating build/temp.macosx-10.9-universal2-3.9/MySQLdb
    gcc -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/zlib/include -I/opt/homebrew/opt/bzip2/include -I/opt/homebrew/opt/openssl@1.1/include -Dversion_info=(2,0,3,'final',0) -D__version__=2.0.3 -I/opt/homebrew/Cellar/mysql/8.0.25_1/include/mysql -I/Users/b0223621/Documents/diit/diit_env/include -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c MySQLdb/_mysql.c -o build/temp.macosx-10.9-universal2-3.9/MySQLdb/_mysql.o -std=c99
    gcc -bundle -undefined dynamic_lookup -arch arm64 -arch x86_64 -g -L/opt/homebrew/opt/zlib/lib -L/opt/homebrew/opt/bzip2/lib -L/opt/homebrew/opt/openssl@1.1/lib -I/opt/homebrew/opt/zlib/include -I/opt/homebrew/opt/bzip2/include -I/opt/homebrew/opt/openssl@1.1/include build/temp.macosx-10.9-universal2-3.9/MySQLdb/_mysql.o -L/opt/homebrew/Cellar/mysql/8.0.25_1/lib -lmysqlclient -lzstd -lresolv -o build/lib.macosx-10.9-universal2-3.9/MySQLdb/_mysql.cpython-39-darwin.so
    ld: library not found for -lzstd
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    error: command '/usr/bin/gcc' failed with exit code 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/b0223621/Documents/diit/diit_env/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/qm/kp4ls0ds5q7gh4rtfqy4xxrr0000gn/T/pip-install-fbu018c0/mysqlclient_64e4fa21b76648ff84f8c751e242384d/setup.py'"'"'; __file__='"'"'/private/var/folders/qm/kp4ls0ds5q7gh4rtfqy4xxrr0000gn/T/pip-install-fbu018c0/mysqlclient_64e4fa21b76648ff84f8c751e242384d/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/qm/kp4ls0ds5q7gh4rtfqy4xxrr0000gn/T/pip-record-3wl14yep/install-record.txt --single-version-externally-managed --compile --install-headers /Users/mketan/Documents/diit/diit_env/include/site/python3.9/mysqlclient Check the logs for full command output.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions