MySQLClient 无法通过 pip 在 Macbook Pro M1 上安装最新版本的 Big Sur

时间:2021-06-07 18:21:12

标签: python pip homebrew mysql-connector macos-big-sur

在确保自制软件可以在本地运行后,我刚刚购买了带有 M1 芯片的新 Macbook Pro。我可以 pip 安装除 mysqlclient 之外的任何其他库,并且我通过自制软件安装它没有问题,所以我从下面的错误消息中想知道,这是 mysqlclient 没有针对最新版本的 Big 更新的问题Sur,或者这是新 Mac 本身的问题?知道这对我来说将是一个很好的开始,如果您有关于如何修复它的建议,那就更好了!谢谢!

ERROR: Command errored out with exit status 1:
     command: /Users/danieljonathanschaefer/Desktop/work/401GOVE/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/ht/p0kw7_d11ns61kqmpmfcy6b40000gn/T/pip-install-bifqtsix/mysqlclient_6f9d0caea513420ea2052d60956aab6d/setup.py'"'"'; __file__='"'"'/private/var/folders/ht/p0kw7_d11ns61kqmpmfcy6b40000gn/T/pip-install-bifqtsix/mysqlclient_6f9d0caea513420ea2052d60956aab6d/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/ht/p0kw7_d11ns61kqmpmfcy6b40000gn/T/pip-record-ukcglom_/install-record.txt --single-version-externally-managed --compile --install-headers /Users/danieljonathanschaefer/Desktop/work/401GOVE/include/site/python3.9/mysqlclient
         cwd: /private/var/folders/ht/p0kw7_d11ns61kqmpmfcy6b40000gn/T/pip-install-bifqtsix/mysqlclient_6f9d0caea513420ea2052d60956aab6d/
    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-x86_64-3.9
    creating build/lib.macosx-10.9-x86_64-3.9/MySQLdb
    copying MySQLdb/__init__.py -> build/lib.macosx-10.9-x86_64-3.9/MySQLdb
    copying MySQLdb/_exceptions.py -> build/lib.macosx-10.9-x86_64-3.9/MySQLdb
    copying MySQLdb/connections.py -> build/lib.macosx-10.9-x86_64-3.9/MySQLdb
    copying MySQLdb/converters.py -> build/lib.macosx-10.9-x86_64-3.9/MySQLdb
    copying MySQLdb/cursors.py -> build/lib.macosx-10.9-x86_64-3.9/MySQLdb
    copying MySQLdb/release.py -> build/lib.macosx-10.9-x86_64-3.9/MySQLdb
    copying MySQLdb/times.py -> build/lib.macosx-10.9-x86_64-3.9/MySQLdb
    creating build/lib.macosx-10.9-x86_64-3.9/MySQLdb/constants
    copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.9-x86_64-3.9/MySQLdb/constants
    copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.9-x86_64-3.9/MySQLdb/constants
    copying MySQLdb/constants/CR.py -> build/lib.macosx-10.9-x86_64-3.9/MySQLdb/constants
    copying MySQLdb/constants/ER.py -> build/lib.macosx-10.9-x86_64-3.9/MySQLdb/constants
    copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.9-x86_64-3.9/MySQLdb/constants
    copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.9-x86_64-3.9/MySQLdb/constants
    running build_ext
    building 'MySQLdb._mysql' extension
    creating build/temp.macosx-10.9-x86_64-3.9
    creating build/temp.macosx-10.9-x86_64-3.9/MySQLdb
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -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/danieljonathanschaefer/Desktop/work/401GOVE/include -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c MySQLdb/_mysql.c -o build/temp.macosx-10.9-x86_64-3.9/MySQLdb/_mysql.o -std=c99
    gcc -bundle -undefined dynamic_lookup -arch x86_64 -g -L/opt/homebrew/opt/openssl@1.1/lib -I/opt/homebrew/opt/openssl@1.1/include build/temp.macosx-10.9-x86_64-3.9/MySQLdb/_mysql.o -L/opt/homebrew/Cellar/mysql/8.0.25_1/lib -lmysqlclient -lzstd -lresolv -o build/lib.macosx-10.9-x86_64-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/danieljonathanschaefer/Desktop/work/401GOVE/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/ht/p0kw7_d11ns61kqmpmfcy6b40000gn/T/pip-install-bifqtsix/mysqlclient_6f9d0caea513420ea2052d60956aab6d/setup.py'"'"'; __file__='"'"'/private/var/folders/ht/p0kw7_d11ns61kqmpmfcy6b40000gn/T/pip-install-bifqtsix/mysqlclient_6f9d0caea513420ea2052d60956aab6d/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/ht/p0kw7_d11ns61kqmpmfcy6b40000gn/T/pip-record-ukcglom_/install-record.txt --single-version-externally-managed --compile --install-headers /Users/danieljonathanschaefer/Desktop/work/401GOVE/include/site/python3.9/mysqlclient Check the logs for full command output.

2 个答案:

答案 0 :(得分:1)

我遇到了同样的问题,我找到了这个命令,

brew install mysql-client

来源:https://doesitarm.com/formula/mysql-client/

答案 1 :(得分:0)

更新: 问题是由于我在虚拟机上运行它,我仍然不能 100% 确定为什么会出现这种情况,但是如果我直接在本地机器上 pip install mysqlclient ,则没有问题。不知道为什么会这样,因为它在我以前的 mac 上没有问题。