文档章节

MacOS install mysqlclinet-python

ArcticF0X
 ArcticF0X
发布于 2019/05/20 15:10
字数 1581
阅读 146
收藏 0

在MacOS上直接使用pip install mysqlclient 会出现如下错误:

Installing initially failed dependencies…
[pipenv.exceptions.InstallError]:   File "/Users/livenuxchau/Library/Python/3.7/lib/python/site-packages/pipenv/core.py", line 1992, in do_install
[pipenv.exceptions.InstallError]:       skip_lock=skip_lock,
[pipenv.exceptions.InstallError]:   File "/Users/livenuxchau/Library/Python/3.7/lib/python/site-packages/pipenv/core.py", line 1253, in do_init
[pipenv.exceptions.InstallError]:       pypi_mirror=pypi_mirror,
[pipenv.exceptions.InstallError]:   File "/Users/livenuxchau/Library/Python/3.7/lib/python/site-packages/pipenv/core.py", line 859, in do_install_dependencies
[pipenv.exceptions.InstallError]:       retry_list, procs, failed_deps_queue, requirements_dir, **install_kwargs
[pipenv.exceptions.InstallError]:   File "/Users/livenuxchau/Library/Python/3.7/lib/python/site-packages/pipenv/core.py", line 763, in batch_install
[pipenv.exceptions.InstallError]:       _cleanup_procs(procs, not blocking, failed_deps_queue, retry=retry)
[pipenv.exceptions.InstallError]:   File "/Users/livenuxchau/Library/Python/3.7/lib/python/site-packages/pipenv/core.py", line 681, in _cleanup_procs
[pipenv.exceptions.InstallError]:       raise exceptions.InstallError(c.dep.name, extra=err_lines)
[pipenv.exceptions.InstallError]: ['Collecting mysqlclient==1.4.2.post1 (from -r /var/folders/7z/pv31dmgj7gx7qfm5qsg2sg280000gn/T/pipenv-xn70eo86-requirements/pipenv-zfsie9b0-requirement.txt (line 1))', '  Using cached https://files.pythonhosted.org/packages/f4/f1/3bb6f64ca7a429729413e6556b7ba5976df06019a5245a43d36032f1061e/mysqlclient-1.4.2.post1.tar.gz']
[pipenv.exceptions.InstallError]: ['ERROR: Complete output from command python setup.py egg_info:', '    ERROR: Traceback (most recent call last):', '      File "<string>", line 1, in <module>', '      File "/private/var/folders/7z/pv31dmgj7gx7qfm5qsg2sg280000gn/T/pip-install-efqet_ya/mysqlclient/setup.py", line 16, in <module>', '        metadata, options = get_config()', '      File "/private/var/folders/7z/pv31dmgj7gx7qfm5qsg2sg280000gn/T/pip-install-efqet_ya/mysqlclient/setup_posix.py", line 53, in get_config', "        libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]", '      File "/private/var/folders/7z/pv31dmgj7gx7qfm5qsg2sg280000gn/T/pip-install-efqet_ya/mysqlclient/setup_posix.py", line 53, in <listcomp>', "        libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]", '      File "/private/var/folders/7z/pv31dmgj7gx7qfm5qsg2sg280000gn/T/pip-install-efqet_ya/mysqlclient/setup_posix.py", line 12, in dequote', '        raise Exception("Wrong MySQL configuration: maybe https://bugs.mysql.com/bug.php?id=86971 ?")', '    Exception: Wrong MySQL configuration: maybe https://bugs.mysql.com/bug.php?id=86971 ?', '    ----------------------------------------', 'ERROR: Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/7z/pv31dmgj7gx7qfm5qsg2sg280000gn/T/pip-install-efqet_ya/mysqlclient/']
ERROR: ERROR: Package installation failed...

根据官方提示这是 MySQL Connector/C 在 MacOS 上的一个BUG. 解决:

  1. 移除 mysql-connector-c 这个包,使用 mysql 这个包中的 mysql_config (未验证)
brew remove mysql-connector-c
brew install mysql
  1. 修改 /usr/local/opt/mysql-connector-c/bin/mysql_config Change
# on macOS, on or about line 112:
# Create options
libs="-L$pkglibdir"
libs="$libs -l "

to

# Create options
libs="-L$pkglibdir"
libs="$libs -lmysqlclient -lssl -lcrypto"

这里执行安装还会提示

Installing initially failed dependencies…
[pipenv.exceptions.InstallError]:   File "/Users/livenuxchau/Library/Python/3.7/lib/python/site-packages/pipenv/core.py", line 1992, in do_install
[pipenv.exceptions.InstallError]:       skip_lock=skip_lock,
[pipenv.exceptions.InstallError]:   File "/Users/livenuxchau/Library/Python/3.7/lib/python/site-packages/pipenv/core.py", line 1253, in do_init
[pipenv.exceptions.InstallError]:       pypi_mirror=pypi_mirror,
[pipenv.exceptions.InstallError]:   File "/Users/livenuxchau/Library/Python/3.7/lib/python/site-packages/pipenv/core.py", line 859, in do_install_dependencies
[pipenv.exceptions.InstallError]:       retry_list, procs, failed_deps_queue, requirements_dir, **install_kwargs
[pipenv.exceptions.InstallError]:   File "/Users/livenuxchau/Library/Python/3.7/lib/python/site-packages/pipenv/core.py", line 763, in batch_install
[pipenv.exceptions.InstallError]:       _cleanup_procs(procs, not blocking, failed_deps_queue, retry=retry)
[pipenv.exceptions.InstallError]:   File "/Users/livenuxchau/Library/Python/3.7/lib/python/site-packages/pipenv/core.py", line 681, in _cleanup_procs
[pipenv.exceptions.InstallError]:       raise exceptions.InstallError(c.dep.name, extra=err_lines)
[pipenv.exceptions.InstallError]: ['Collecting mysqlclient==1.4.2.post1 (from -r /var/folders/7z/pv31dmgj7gx7qfm5qsg2sg280000gn/T/pipenv-ytkx2ron-requirements/pipenv-as_zui3n-requirement.txt (line 1))', '  Using cached https://files.pythonhosted.org/packages/f4/f1/3bb6f64ca7a429729413e6556b7ba5976df06019a5245a43d36032f1061e/mysqlclient-1.4.2.post1.tar.gz', 'Building wheels for collected packages: mysqlclient', '  Building wheel for mysqlclient (setup.py): started', "  Building wheel for mysqlclient (setup.py): finished with status 'error'", '  Running setup.py clean for mysqlclient', 'Failed to build mysqlclient', 'Installing collected packages: mysqlclient', '  Running setup.py install for mysqlclient: started', "    Running setup.py install for mysqlclient: finished with status 'error'"]
[pipenv.exceptions.InstallError]: ['ERROR: Complete output from command /Users/livenuxchau/.local/share/virtualenvs/mysqlclient-python-iMwOAUiC/bin/python3.7 -u -c \'import setuptools, tokenize;__file__=\'"\'"\'/private/var/folders/7z/pv31dmgj7gx7qfm5qsg2sg280000gn/T/pip-install-ae6uspfp/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/7z/pv31dmgj7gx7qfm5qsg2sg280000gn/T/pip-wheel-v2hkq3po --python-tag cp37:', '  ERROR: running bdist_wheel', '  running build', '  running build_py', '  creating build', '  creating build/lib.macosx-10.14-x86_64-3.7', '  creating build/lib.macosx-10.14-x86_64-3.7/MySQLdb', '  copying MySQLdb/__init__.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb', '  copying MySQLdb/_exceptions.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb', '  copying MySQLdb/compat.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb', '  copying MySQLdb/connections.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb', '  copying MySQLdb/converters.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb', '  copying MySQLdb/cursors.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb', '  copying MySQLdb/release.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb', '  copying MySQLdb/times.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb', '  creating build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants', '  copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants', '  copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants', '  copying MySQLdb/constants/CR.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants', '  copying MySQLdb/constants/ER.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants', '  copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants', '  copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants', '  warning: build_py: byte-compiling is disabled, skipping.', '  ', '  running build_ext', "  building 'MySQLdb._mysql' extension", '  creating build/temp.macosx-10.14-x86_64-3.7', '  creating build/temp.macosx-10.14-x86_64-3.7/MySQLdb', "  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -Dversion_info=(1,4,2,'post',1) -D__version__=1.4.2.post1 -I/usr/local/Cellar/mysql-connector-c/6.1.11/include -I/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c MySQLdb/_mysql.c -o build/temp.macosx-10.14-x86_64-3.7/MySQLdb/_mysql.o", '  clang -bundle -undefined dynamic_lookup build/temp.macosx-10.14-x86_64-3.7/MySQLdb/_mysql.o -L/usr/local/Cellar/mysql-connector-c/6.1.11/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.14-x86_64-3.7/MySQLdb/_mysql.cpython-37m-darwin.so', '  ld: library not found for -lssl', '  clang: error: linker command failed with exit code 1 (use -v to see invocation)', "  error: command 'clang' failed with exit status 1", '  ----------------------------------------', '  ERROR: Failed building wheel for mysqlclient', '    ERROR: Complete output from command /Users/livenuxchau/.local/share/virtualenvs/mysqlclient-python-iMwOAUiC/bin/python3.7 -u -c \'import setuptools, tokenize;__file__=\'"\'"\'/private/var/folders/7z/pv31dmgj7gx7qfm5qsg2sg280000gn/T/pip-install-ae6uspfp/mysqlclient/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/7z/pv31dmgj7gx7qfm5qsg2sg280000gn/T/pip-record-h8n9nbh8/install-record.txt --single-version-externally-managed --compile --install-headers /Users/livenuxchau/.local/share/virtualenvs/mysqlclient-python-iMwOAUiC/bin/../include/site/python3.7/mysqlclient:', '    ERROR: running install', '    running build', '    running build_py', '    creating build', '    creating build/lib.macosx-10.14-x86_64-3.7', '    creating build/lib.macosx-10.14-x86_64-3.7/MySQLdb', '    copying MySQLdb/__init__.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb', '    copying MySQLdb/_exceptions.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb', '    copying MySQLdb/compat.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb', '    copying MySQLdb/connections.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb', '    copying MySQLdb/converters.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb', '    copying MySQLdb/cursors.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb', '    copying MySQLdb/release.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb', '    copying MySQLdb/times.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb', '    creating build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants', '    copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants', '    copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants', '    copying MySQLdb/constants/CR.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants', '    copying MySQLdb/constants/ER.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants', '    copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants', '    copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.14-x86_64-3.7/MySQLdb/constants', '    warning: build_py: byte-compiling is disabled, skipping.', '    ', '    running build_ext', "    building 'MySQLdb._mysql' extension", '    creating build/temp.macosx-10.14-x86_64-3.7', '    creating build/temp.macosx-10.14-x86_64-3.7/MySQLdb', "    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -Dversion_info=(1,4,2,'post',1) -D__version__=1.4.2.post1 -I/usr/local/Cellar/mysql-connector-c/6.1.11/include -I/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c MySQLdb/_mysql.c -o build/temp.macosx-10.14-x86_64-3.7/MySQLdb/_mysql.o", '    clang -bundle -undefined dynamic_lookup build/temp.macosx-10.14-x86_64-3.7/MySQLdb/_mysql.o -L/usr/local/Cellar/mysql-connector-c/6.1.11/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.14-x86_64-3.7/MySQLdb/_mysql.cpython-37m-darwin.so', '    ld: library not found for -lssl', '    clang: error: linker command failed with exit code 1 (use -v to see invocation)', "    error: command 'clang' failed with exit status 1", '    ----------------------------------------', 'ERROR: Command "/Users/livenuxchau/.local/share/virtualenvs/mysqlclient-python-iMwOAUiC/bin/python3.7 -u -c \'import setuptools, tokenize;__file__=\'"\'"\'/private/var/folders/7z/pv31dmgj7gx7qfm5qsg2sg280000gn/T/pip-install-ae6uspfp/mysqlclient/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/7z/pv31dmgj7gx7qfm5qsg2sg280000gn/T/pip-record-h8n9nbh8/install-record.txt --single-version-externally-managed --compile --install-headers /Users/livenuxchau/.local/share/virtualenvs/mysqlclient-python-iMwOAUiC/bin/../include/site/python3.7/mysqlclient" failed with error code 1 in /private/var/folders/7z/pv31dmgj7gx7qfm5qsg2sg280000gn/T/pip-install-ae6uspfp/mysqlclient/']

ld: library not found for -lssl' 找不到 openssl 库文件,执行下面命令再执行pip install 就 OK

export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"

© 著作权归作者所有

ArcticF0X

ArcticF0X

粉丝 6
博文 10
码字总数 2877
作品 0
长沙
私信 提问
加载中

评论(0)

新版 macOS 默认不包含脚本语言运行时,并将移除 Python 2.7

根据 macOS 下一个主要版本 10.15(macOS Catalina) 的发布说明,从该版本起,macOS 默认不包含脚本语言运行时。 在发布说明中苹果称,为了保持与旧版软件的兼容性,macOS 默认包含了脚本语...

局长
2019/06/07
5.8K
17
Install the AWS CLI Using the Bundled Installer (Linux, macOS, or Unix)

On Linux, macOS, or Unix, you can also use the bundled installer to install the AWS CLI. The bundled installer includes all dependencies and can be used offline. Important The b......

qwfys
2018/12/05
25
0
PyObjC 6.0 发布,Python 和 Objective-C 的交互接口

PyObjC 旨在为 Python 和 Objective-C 两种语言之间提供交互的接口。6.0 版本已经发布了,此版本有两个最重要的更改,分别是增加了对 MacOS 10.15 (Catalina)中引入的框架和 API 的支持,以及...

afterer
2019/10/23
1K
0
如何在macOS或OS X上安装pip? - How do I install pip on macOS or OS X?

问题: I spent most of the day yesterday searching for a clear answer for installing (package manager for Python). 昨天我大部分时间都在寻找安装 (Python的软件包管理器)的明确答案...

javail
03/31
5
0
使用 Conda 管理 MacOS 上的 Ansible 环境

Conda 将 Ansible 所需的一切都收集到虚拟环境中并将其与其他项目分开。 如果你是一名使用 MacOS 并涉及到 Ansible 管理的 Python 开发人员,你可能希望使用 Conda 包管理器将 Ansible 的工作...

作者: James Farrell
2019/09/18
0
0

没有更多内容

加载失败,请刷新页面

加载更多

项目讲解4

分组取topN的方法: 数据的预处理为使用mapreduce 每日新访客: 回头/单次访客统计: 漏斗模型: 使用python产生数据 1.统计每个步骤的总访问人数 create table tmp_page_views like ods_web...

七宝1
45分钟前
57
0
笔记:pyecharts可视化

# 加载数据import pandas as pddf = pd.read_excel(r"D:\我的文档\数据源\采购商品出库综合查询 - Python.xlsx",header = 2)df # 计算出结果df1 = df.groupby(["部门"])["总销售额"......

tengyulong
57分钟前
64
0
如何在div中垂直对齐图像 - How to vertically align an image inside a div

问题: How can you align an image inside of a containing div ? 如何在包含div内部对齐图像? Example 例 In my example, I need to vertically center the <img> in the <div> with cla......

javail
今天
59
0
用原生JS模拟Vue的State插件的写法

<html><body> <input type="text" id="myinput"></body><script> var myinput = document.querySelector('#myinput'); function Vue() { } Vue.Use = function......

lilugirl
今天
81
0
space_sniffer 清理 磁盘

http://www.uderzo.it/main_products/space_sniffer/ 下载直接运行 , 可以看到占用空间比较大的一些文件夹, 然后根据情况删除 anaconda和pr的缓存占了很大一部分 金山居然也这么大?...

阿豪boy
今天
85
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部