简体   繁体   English

在 Mac 上安装 mysqlclient 时出错

[英]Getting error while installing mysqlclient on Mac

I am trying to install mysqlclient on macOS BigSur(running on M1 chip mac) as a part of implementing django project using MySQL DB.作为使用 MySQL DB 实施 django 项目的一部分,我正在尝试在 macOS BigSur 上安装 mysqlclient(在 M1 芯片 mac 上运行)。 However, I am getting below error:但是,我收到以下错误:

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: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/rs/vv5212l55ys7lk0vx4p87gxw0000gn/T/pip-install-73_o12ze/mysqlclient_23e4f763c971433c863260eda891b9d0/setup.py'"'"'; __file__='"'"'/private/var/folders/rs/vv5212l55ys7lk0vx4p87gxw0000gn/T/pip-install-73_o12ze/mysqlclient_23e4f763c971433c863260eda891b9d0/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/rs/vv5212l55ys7lk0vx4p87gxw0000gn/T/pip-record-jl3d35rj/install-record.txt --single-version-externally-managed --compile --install-headers /Library/Frameworks/Python.framework/Versions/3.9/include/python3.9/mysqlclient
         cwd: /private/var/folders/rs/vv5212l55ys7lk0vx4p87gxw0000gn/T/pip-install-73_o12ze/mysqlclient_23e4f763c971433c863260eda891b9d0/
    Complete output (41 lines):
    mysql_config --version
    ['8.0.22']
    mysql_config --libs
    ['-L/usr/local/mysql/lib', '-lmysqlclient', '-lssl', '-lcrypto', '-lresolv']
    mysql_config --cflags
    ['-I/usr/local/mysql/include']
    ext_options:
      library_dirs: ['/usr/local/mysql/lib']
      libraries: ['mysqlclient', 'resolv']
      extra_compile_args: ['-std=c99']
      extra_link_args: []
      include_dirs: ['/usr/local/mysql/include']
      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/usr/local/opt/openssl@1.1/include -Dversion_info=(2,0,3,'final',0) -D__version__=2.0.3 -I/usr/local/mysql/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
    xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
    error: command '/usr/bin/gcc' failed with exit code 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/rs/vv5212l55ys7lk0vx4p87gxw0000gn/T/pip-install-73_o12ze/mysqlclient_23e4f763c971433c863260eda891b9d0/setup.py'"'"'; __file__='"'"'/private/var/folders/rs/vv5212l55ys7lk0vx4p87gxw0000gn/T/pip-install-73_o12ze/mysqlclient_23e4f763c971433c863260eda891b9d0/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/rs/vv5212l55ys7lk0vx4p87gxw0000gn/T/pip-record-jl3d35rj/install-record.txt --single-version-externally-managed --compile --install-headers /Library/Frameworks/Python.framework/Versions/3.9/include/python3.9/mysqlclient Check the logs for full command output.

Please note that I have already checked out many questions opened for this same issue.请注意,我已经检查了针对同一问题打开的许多问题。 But none of the suggested fix working for me.但是没有一个建议的修复对我有用。 Please help请帮忙

This Issue is fixed now for me and for that I did 2 things: 1 - Installed wheel package这个问题现在为我解决了,为此我做了两件事:1 - 安装轮子 package

pip3 install wheel

2 - I followed this thread - Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) 2 - 我关注了这个线程 - Git 在 macOS 更新后不起作用(xcrun:错误:无效的活动开发者路径(/Library/Developer/CommandLineTools)

try to install the latest version of mysqlclient尝试安装最新版本的mysqlclient

mysqlclient==2.0.3

version 2.0.3 worked for me in python 3.9 (win) 2.0.3 版在 python 3.9 中为我工作(赢)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM