【问题标题】:Error in installing mysqlclient on mac with python 3.6使用 python 3.6 在 mac 上安装 mysqlclient 时出错
【发布时间】:2020-06-10 05:21:15
【问题描述】:

我在安装 mysqlclient 时在 python 中遇到以下问题:

 Building wheel for mysqlclient (setup.py) ... error
 ERROR: Command errored out with exit status 1:
 command: /Users/joy/workspace/my_project/venv/bin/python -u -c 'import sys, setuptools, 
 tokenize; sys.argv[0] = '"'"'/private/var/folders/rz/qj7p_p1n2d38w4ysr50qvgfc0000gp/T/pip- 
 install-tfjwlop6/mysqlclient/setup.py'"'"'; 
 __file__='"'"'/private/var/folders/rz/qj7p_p1n2d38w4ysr50qvgfc0000gp/T/pip-install- 
 tfjwlop6/mysqlclient/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open). 
 (__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, 
 __file__, '"'"'exec'"'"'))' bdist_wheel -d 
/private/var/folders/rz/qj7p_p1n2d38w4ysr50qvgfc0000gp/T/pip-wheel-s9xhvytf
   cwd: /private/var/folders/rz/qj7p_p1n2d38w4ysr50qvgfc0000gp/T/pip-install- 
tfjwlop6/mysqlclient/
Complete output (30 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-3.6
copying _mysql_exceptions.py -> build/lib.macosx-10.9-x86_64-3.6
creating build/lib.macosx-10.9-x86_64-3.6/MySQLdb
copying MySQLdb/__init__.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb
copying MySQLdb/compat.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb
copying MySQLdb/connections.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb
copying MySQLdb/converters.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb
copying MySQLdb/cursors.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb
copying MySQLdb/release.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb
copying MySQLdb/times.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb
creating build/lib.macosx-10.9-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.9-x86_64-
3.6/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.9-x86_64-3.6/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.macosx-10.9-x86_64-3.6
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g - 
fwrapv -O3 -Wall -Wstrict-prototypes -arch x86_64 -g -Dversion_info=(1,3,13,'final',0) -
D__version__=1.3.13 -I/usr/local/Cellar/mysql@5.7/5.7.29/include/mysql -
I/Users/joy/workspace/my_project/venv/include -
I/Library/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c _mysql.c -o 
build/temp.macosx-10.9-x86_64-3.6/_mysql.o
gcc -bundle -undefined dynamic_lookup -arch x86_64 -g build/temp.macosx-10.9-x86_64-
3.6/_mysql.o -L/usr/local/Cellar/mysql@5.7/5.7.29/lib -lmysqlclient -lssl -lcrypto -o 
build/lib.macosx-10.9-x86_64-3.6/_mysql.cpython-36m-darwin.so
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for mysqlclient

在这方面,我在这里浏览了几篇文章,但没有得到任何关于如何在我的 Mac 上解决此问题的线索。

【问题讨论】:

    标签: python mysql python-3.x macos


    【解决方案1】:

    你还没有安装 gcc 编译器。如果我是正确的,它带有“命令行工具 voor XCode”。所以你所要做的就是去应用商店下载 XCode。

    您可以通过在终端中运行gcc -v 来检查它是否已安装。

    【讨论】:

    • @ensjeflensje,gcc 已安装:$gcc -v 配置为:--prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/ CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1 Apple LLVM 版本 10.0.1 (clang-1001.0.46.4) 目标:x86_64-apple-darwin18.7.0 线程模型:posix InstalledDir: /Library/开发者/CommandLineTools/usr/bin
    猜你喜欢
    • 2023-03-30
    • 1970-01-01
    • 1970-01-01
    • 2018-12-11
    • 1970-01-01
    • 2018-01-15
    • 2019-06-18
    相关资源
    最近更新 更多