微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Mac:为 mysqlclient 运行 setup.py install ... 错误

如何解决Mac:为 mysqlclient 运行 setup.py install ... 错误

我正在从 linux 切换到 mac。在 linux 中,当应用程序给我诸如“MysqLclient 配置不正确”之类的错误时,我曾经在项目环境中以及全局安装 MysqLclient。但是在 mac 中我似乎找不到方法。这是我尝试在项目环境中安装 MysqLclient 时的回溯。

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/macbookpro/kalke-services/services/venv/bin/python3 -u -c 'import sys,setuptools,tokenize; sys.argv[0] = '"'"'/private/var/folders/_k/74wl7dz56txbh904slsgt2180000gn/T/pip-install-1y50fx7i/MysqLclient_f48588e55e2a4270a35a2d3c79c1d000/setup.py'"'"'; __file__='"'"'/private/var/folders/_k/74wl7dz56txbh904slsgt2180000gn/T/pip-install-1y50fx7i/MysqLclient_f48588e55e2a4270a35a2d3c79c1d000/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/_k/74wl7dz56txbh904slsgt2180000gn/T/pip-record-fgig7hxx/install-record.txt --single-version-externally-managed --compile --install-headers /Users/macbookpro/kalke-services/services/venv/include/site/python3.8/MysqLclient
         cwd: /private/var/folders/_k/74wl7dz56txbh904slsgt2180000gn/T/pip-install-1y50fx7i/MysqLclient_f48588e55e2a4270a35a2d3c79c1d000/
    Complete output (132 lines):
    MysqL_config --version
    ['8.0.23']
    MysqL_config --libs
    ['-L/usr/local/opt/MysqL-client/lib','-lMysqLclient','-lssl','-lcrypto','-lresolv']
    MysqL_config --cflags
    ['-I/usr/local/opt/MysqL-client/include/MysqL']
    ext_options:
      library_dirs: ['/usr/local/opt/MysqL-client/lib']
      libraries: ['MysqLclient','resolv']
      extra_compile_args: ['-std=c99']
      extra_link_args: []
      include_dirs: ['/usr/local/opt/MysqL-client/include/MysqL']
      extra_objects: []
      define_macros: [('version_info',"(2,3,'final',0)"),('__version__','2.0.3')]
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.14.6-x86_64-3.8
    creating build/lib.macosx-10.14.6-x86_64-3.8/MysqLdb
    copying MysqLdb/__init__.py -> build/lib.macosx-10.14.6-x86_64-3.8/MysqLdb
    copying MysqLdb/_exceptions.py -> build/lib.macosx-10.14.6-x86_64-3.8/MysqLdb
    copying MysqLdb/connections.py -> build/lib.macosx-10.14.6-x86_64-3.8/MysqLdb
    copying MysqLdb/converters.py -> build/lib.macosx-10.14.6-x86_64-3.8/MysqLdb
    copying MysqLdb/cursors.py -> build/lib.macosx-10.14.6-x86_64-3.8/MysqLdb
    copying MysqLdb/release.py -> build/lib.macosx-10.14.6-x86_64-3.8/MysqLdb
    copying MysqLdb/times.py -> build/lib.macosx-10.14.6-x86_64-3.8/MysqLdb
    creating build/lib.macosx-10.14.6-x86_64-3.8/MysqLdb/constants
    copying MysqLdb/constants/__init__.py -> build/lib.macosx-10.14.6-x86_64-3.8/MysqLdb/constants
    copying MysqLdb/constants/CLIENT.py -> build/lib.macosx-10.14.6-x86_64-3.8/MysqLdb/constants
    copying MysqLdb/constants/CR.py -> build/lib.macosx-10.14.6-x86_64-3.8/MysqLdb/constants
    copying MysqLdb/constants/ER.py -> build/lib.macosx-10.14.6-x86_64-3.8/MysqLdb/constants
    copying MysqLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.14.6-x86_64-3.8/MysqLdb/constants
    copying MysqLdb/constants/FLAG.py -> build/lib.macosx-10.14.6-x86_64-3.8/MysqLdb/constants
    running build_ext
    building 'MysqLdb._MysqL' extension
    creating build/temp.macosx-10.14.6-x86_64-3.8
    creating build/temp.macosx-10.14.6-x86_64-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 -Dversion_info=(2,0) -D__version__=2.0.3 -I/usr/local/opt/MysqL-client/include/MysqL -I/Users/macbookpro/kalke-services/services/venv/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-x86_64-3.8/MysqLdb/_MysqL.o -std=c99
    In file included from MysqLdb/_MysqL.c:29:
    In file included from /usr/local/opt/MysqL-client/include/MysqL/MysqL.h:45:
    In file included from /Library/Developer/CommandLinetools/usr/lib/clang/12.0.0/include/stdint.h:52:
    In file included from /Library/Developer/CommandLinetools/SDKs/MacOSX10.15.sdk/usr/include/stdint.h:52:
    In file included from /Library/Developer/CommandLinetools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:32:
    /Library/Developer/CommandLinetools/SDKs/MacOSX10.15.sdk/usr/include/sys/cdefs.h:807:2: error: Unsupported architecture
    #error Unsupported architecture
     ^
    In file included from MysqLdb/_MysqL.c:29:
    In file included from /usr/local/opt/MysqL-client/include/MysqL/MysqL.h:45:
    In file included from /Library/Developer/CommandLinetools/usr/lib/clang/12.0.0/include/stdint.h:52:
    In file included from /Library/Developer/CommandLinetools/SDKs/MacOSX10.15.sdk/usr/include/stdint.h:52:
    In file included from /Library/Developer/CommandLinetools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:33:
    /Library/Developer/CommandLinetools/SDKs/MacOSX10.15.sdk/usr/include/machine/_types.h:34:2: error: architecture not supported
    #error architecture not supported
     ^
    In file included from MysqLdb/_MysqL.c:29:
    In file included from /usr/local/opt/MysqL-client/include/MysqL/MysqL.h:45:
    In file included from /Library/Developer/CommandLinetools/usr/lib/clang/12.0.0/include/stdint.h:52:
    In file included from /Library/Developer/CommandLinetools/SDKs/MacOSX10.15.sdk/usr/include/stdint.h:52:
    /Library/Developer/CommandLinetools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:55:9: error: unkNown type name '__int64_t'
    typedef __int64_t       __darwin_blkcnt_t;      /* total blocks */
            ^
    /Library/Developer/CommandLinetools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:56:9: error: unkNown type name '__int32_t'
    typedef __int32_t       __darwin_blksize_t;     /* preferred block size */
            ^
    /Library/Developer/CommandLinetools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:57:9: error: unkNown type name '__int32_t'
    typedef __int32_t       __darwin_dev_t;         /* dev_t */
            ^
    /Library/Developer/CommandLinetools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:60:9: error: unkNown type name '__uint32_t'
    typedef __uint32_t      __darwin_gid_t;         /* [???] process and group IDs */
            ^
    /Library/Developer/CommandLinetools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:61:9: error: unkNown type name '__uint32_t'
    typedef __uint32_t      __darwin_id_t;          /* [XSI] pid_t,uid_t,or gid_t*/
            ^
    /Library/Developer/CommandLinetools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:62:9: error: unkNown type name '__uint64_t'; did you mean 'uint64_t'?
    typedef __uint64_t      __darwin_ino64_t;       /* [???] Used for 64 bit inodes */
            ^
    /Library/Developer/CommandLinetools/SDKs/MacOSX10.15.sdk/usr/include/_types/_uint64_t.h:31:28: note: 'uint64_t' declared here
    typedef unsigned long long uint64_t;
                               ^
    In file included from MysqLdb/_MysqL.c:29:
    In file included from /usr/local/opt/MysqL-client/include/MysqL/MysqL.h:45:
    In file included from /Library/Developer/CommandLinetools/usr/lib/clang/12.0.0/include/stdint.h:52:
    In file included from /Library/Developer/CommandLinetools/SDKs/MacOSX10.15.sdk/usr/include/stdint.h:52:
    /Library/Developer/CommandLinetools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:68:9: error: unkNown type name '__darwin_natural_t'
    typedef __darwin_natural_t __darwin_mach_port_name_t; /* Used by mach */
            ^
    /Library/Developer/CommandLinetools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:70:9: error: unkNown type name '__uint16_t'
    typedef __uint16_t      __darwin_mode_t;        /* [???] Some file attributes */
            ^
    /Library/Developer/CommandLinetools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:71:9: error: unkNown type name '__int64_t'
    typedef __int64_t       __darwin_off_t;         /* [???] Used for file sizes */
            ^
    /Library/Developer/CommandLinetools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:72:9: error: unkNown type name '__int32_t'
    typedef __int32_t       __darwin_pid_t;         /* [???] process and group IDs */
            ^
    /Library/Developer/CommandLinetools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:73:9: error: unkNown type name '__uint32_t'
    typedef __uint32_t      __darwin_sigset_t;      /* [???] signal set */
            ^
    /Library/Developer/CommandLinetools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:74:9: error: unkNown type name '__int32_t'
    typedef __int32_t       __darwin_suseconds_t;   /* [???] microseconds */
            ^
    /Library/Developer/CommandLinetools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:75:9: error: unkNown type name '__uint32_t'
    typedef __uint32_t      __darwin_uid_t;         /* [???] user IDs */
            ^
    /Library/Developer/CommandLinetools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:76:9: error: unkNown type name '__uint32_t'
    typedef __uint32_t      __darwin_useconds_t;    /* [???] microseconds */
            ^
    In file included from MysqLdb/_MysqL.c:29:
    In file included from /usr/local/opt/MysqL-client/include/MysqL/MysqL.h:45:
    In file included from /Library/Developer/CommandLinetools/usr/lib/clang/12.0.0/include/stdint.h:52:
    In file included from /Library/Developer/CommandLinetools/SDKs/MacOSX10.15.sdk/usr/include/stdint.h:53:
    In file included from /Library/Developer/CommandLinetools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types/_intptr_t.h:30:
    /Library/Developer/CommandLinetools/SDKs/MacOSX10.15.sdk/usr/include/machine/types.h:37:2: error: architecture not supported
    #error architecture not supported
     ^
    In file included from MysqLdb/_MysqL.c:29:
    In file included from /usr/local/opt/MysqL-client/include/MysqL/MysqL.h:45:
    In file included from /Library/Developer/CommandLinetools/usr/lib/clang/12.0.0/include/stdint.h:52:
    In file included from /Library/Developer/CommandLinetools/SDKs/MacOSX10.15.sdk/usr/include/stdint.h:53:
    /Library/Developer/CommandLinetools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types/_intptr_t.h:32:9: error: unkNown type name '__darwin_intptr_t'
    typedef __darwin_intptr_t       intptr_t;
            ^
    In file included from MysqLdb/_MysqL.c:29:
    In file included from /usr/local/opt/MysqL-client/include/MysqL/MysqL.h:46:
    In file included from /Library/Developer/CommandLinetools/SDKs/MacOSX10.15.sdk/usr/include/sys/types.h:81:
    /Library/Developer/CommandLinetools/SDKs/MacOSX10.15.sdk/usr/include/machine/endian.h:37:2: error: architecture not supported
    #error architecture not supported
     ^
    Fatal error: too many errors emitted,stopping Now [-ferror-limit=]
    20 errors generated.
    error: command 'clang' Failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/macbookpro/kalke-services/services/venv/bin/python3 -u -c 'import sys,'"'"'exec'"'"'))' install --record /private/var/folders/_k/74wl7dz56txbh904slsgt2180000gn/T/pip-record-fgig7hxx/install-record.txt --single-version-externally-managed --compile --install-headers /Users/macbookpro/kalke-services/services/venv/include/site/python3.8/MysqLclient Check the logs for full command output.
WARNING: You are using pip version 21.0; however,version 21.0.1 is available.
You should consider upgrading via the '/Users/macbookpro/kalke-services/services/venv/bin/python3 -m pip install --upgrade pip' command.

还建议我写 mac 的 python 博客,以便我可以更快地切换到 mac。

解决方法

我的简单解决方案是在项目环境中安装pymysql。

pip install pymysql

然后在项目 settings.py 目录下的 init.py 文件中添加以下代码。

import pymysql
pymysql.install_as_MySQLdb()

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?