HenryM
HenryM

Reputation: 5793

Cannot install mysqlclient in virtualenv on new Mac

I'm trying to get a project I have up and running on a Linux Ubuntu machine on a new MacBook Pro but I'm getting the following error when running pip install mysqlclient within a virtual environment. Please not, it install within issue in the main environment. I'm new to iOS so not sure where to go

Installing collected packages: mysqlclient
    Running setup.py install for mysqlclient ... error
    ERROR: Command errored out with exit status 1:
     command: /Users/henrymehta/Documents/Sites/autumna-dev/env/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/z2/jzds5lqd5x1by73n996bp8h80000gn/T/pip-install-0txl3zk8/mysqlclient_23fd0d586ae74725b1d39618f493158c/setup.py'"'"'; __file__='"'"'/private/var/folders/z2/jzds5lqd5x1by73n996bp8h80000gn/T/pip-install-0txl3zk8/mysqlclient_23fd0d586ae74725b1d39618f493158c/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/z2/jzds5lqd5x1by73n996bp8h80000gn/T/pip-record-9tgr_dbh/install-record.txt --single-version-externally-managed --compile --install-headers /Users/henrymehta/Documents/Sites/autumna-dev/env/include/site/python3.8/mysqlclient
         cwd: /private/var/folders/z2/jzds5lqd5x1by73n996bp8h80000gn/T/pip-install-0txl3zk8/mysqlclient_23fd0d586ae74725b1d39618f493158c/
    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.14.6-arm64-3.8
    creating build/lib.macosx-10.14.6-arm64-3.8/MySQLdb
    copying MySQLdb/__init__.py -> build/lib.macosx-10.14.6-arm64-3.8/MySQLdb
    copying MySQLdb/_exceptions.py -> build/lib.macosx-10.14.6-arm64-3.8/MySQLdb
    copying MySQLdb/connections.py -> build/lib.macosx-10.14.6-arm64-3.8/MySQLdb
    copying MySQLdb/converters.py -> build/lib.macosx-10.14.6-arm64-3.8/MySQLdb
    copying MySQLdb/cursors.py -> build/lib.macosx-10.14.6-arm64-3.8/MySQLdb
    copying MySQLdb/release.py -> build/lib.macosx-10.14.6-arm64-3.8/MySQLdb
    copying MySQLdb/times.py -> build/lib.macosx-10.14.6-arm64-3.8/MySQLdb
    creating build/lib.macosx-10.14.6-arm64-3.8/MySQLdb/constants
    copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.14.6-arm64-3.8/MySQLdb/constants
    copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.14.6-arm64-3.8/MySQLdb/constants
    copying MySQLdb/constants/CR.py -> build/lib.macosx-10.14.6-arm64-3.8/MySQLdb/constants
    copying MySQLdb/constants/ER.py -> build/lib.macosx-10.14.6-arm64-3.8/MySQLdb/constants
    copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.14.6-arm64-3.8/MySQLdb/constants
    copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.14.6-arm64-3.8/MySQLdb/constants
    running build_ext
    building 'MySQLdb._mysql' extension
    creating build/temp.macosx-10.14.6-arm64-3.8
    creating build/temp.macosx-10.14.6-arm64-3.8/MySQLdb
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -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/henrymehta/Documents/Sites/autumna-dev/env/include -I/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8 -c MySQLdb/_mysql.c -o build/temp.macosx-10.14.6-arm64-3.8/MySQLdb/_mysql.o -std=c99
    clang -bundle -undefined dynamic_lookup -arch arm64 -arch x86_64 -Wl,-headerpad,0x1000 build/temp.macosx-10.14.6-arm64-3.8/MySQLdb/_mysql.o -L/opt/homebrew/Cellar/mysql/8.0.25_1/lib -lmysqlclient -lzstd -lresolv -o build/lib.macosx-10.14.6-arm64-3.8/MySQLdb/_mysql.cpython-38-darwin.so
    ld: library not found for -lzstd
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    error: command 'clang' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/henrymehta/Documents/Sites/autumna-dev/env/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/z2/jzds5lqd5x1by73n996bp8h80000gn/T/pip-install-0txl3zk8/mysqlclient_23fd0d586ae74725b1d39618f493158c/setup.py'"'"'; __file__='"'"'/private/var/folders/z2/jzds5lqd5x1by73n996bp8h80000gn/T/pip-install-0txl3zk8/mysqlclient_23fd0d586ae74725b1d39618f493158c/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/z2/jzds5lqd5x1by73n996bp8h80000gn/T/pip-record-9tgr_dbh/install-record.txt --single-version-externally-managed --compile --install-headers /Users/henrymehta/Documents/Sites/autumna-dev/env/include/site/python3.8/mysqlclient Check the logs for full command output.

Upvotes: 1

Views: 886

Answers (1)

HenryM
HenryM

Reputation: 5793

this worked for me

brew install zstd
CFLAGS="-I$(brew --prefix)/include" LDFLAGS="-L$(brew --prefix)/lib" pip install mysqlclient

Upvotes: 1

Related Questions