【问题标题】:Cannot install mysqlclient in virtualenv on new Mac无法在新 Mac 上的 virtualenv 中安装 mysqlclient
【发布时间】:2021-08-25 13:19:59
【问题描述】:

我正在尝试在新 MacBook Pro 上的 Linux Ubuntu 机器上启动并运行一个项目,但在虚拟环境中运行 pip install mysqlclient 时出现以下错误。请不要,它安装在主环境中的问题内。我是 iOS 新手,所以不知道该去哪里

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.

【问题讨论】:

    标签: mysql python-3.x macos


    【解决方案1】:

    这对我有用

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

    【讨论】:

    • 唯一对我有用的评论!!!非常感谢!我花了几个小时!!谢谢!!!
    猜你喜欢
    • 2019-07-29
    • 2021-01-06
    • 2015-12-04
    • 1970-01-01
    • 2018-03-14
    • 2019-09-25
    • 2019-04-06
    • 2020-04-16
    • 2018-11-27
    相关资源
    最近更新 更多