Mac安装MySQL-python的血泪史
现象描述
起初正常使用pip命令提示如下的错误:
cc -bundle -undefined dynamic_lookup -Wl,-F. build/temp.macosx-10.14-intel-2.7/_mysql.o -L/usr/local/Cellar/mysql-connector-c/6.1.11/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.14-intel-2.7/_mysql.so
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'cc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for mysql-python
13 warnings generated.
cc -bundle -undefined dynamic_lookup -Wl,-F. build/temp.macosx-10.14-intel-2.7/_mysql.o -L/usr/local/Cellar/mysql-connector-c/6.1.11/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.14-intel-2.7/_mysql.so
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'cc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /Users/wang/.virtualenvs/flask-demo/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/4r/29z_gj1n4szg9r01y5s6rxnm0000gn/T/pip-install-yqjXkS/mysql-python/setup.py'"'"'; __file__='"'"'/private/var/folders/4r/29z_gj1n4szg9r01y5s6rxnm0000gn/T/pip-install-yqjXkS/mysql-python/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/4r/29z_gj1n4szg9r01y5s6rxnm0000gn/T/pip-record-rW5Hej/install-record.txt --single-version-externally-managed --compile --install-headers /Users/wang/.virtualenvs/flask-demo/include/site/python2.7/mysql-python Check the logs for full command output.
大致来看,是cc命令执行失败,没太多的思路,遂谷歌;
尝试
stackoverflow答案
参考上面的链接,执行了一下,甚至也执行了一次评论里的内容,但实际上并没啥用……
后面甚至出现了新的问题……
csdn答案
https://blog.csdn.net/love_parents/article/details/80938818
尝试了后,又提示其他的问题
ERROR: Command errored out with exit status 1:
command: /Users/wang/.virtualenvs/flask-demo/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/4r/29z_gj1n4szg9r01y5s6rxnm0000gn/T/pip-install-xonLuB/mysql-python/setup.py'"'"'; __file__='"'"'/private/var/folders/4r/29z_gj1n4szg9r01y5s6rxnm0000gn/T/pip-install-xonLuB/mysql-python/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/4r/29z_gj1n4szg9r01y5s6rxnm0000gn/T/pip-install-xonLuB/mysql-python/pip-egg-info
cwd: /private/var/folders/4r/29z_gj1n4szg9r01y5s6rxnm0000gn/T/pip-install-xonLuB/mysql-python/
Complete output (9 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/4r/29z_gj1n4szg9r01y5s6rxnm0000gn/T/pip-install-xonLuB/mysql-python/setup.py", line 17, in <module>
metadata, options = get_config()
File "setup_posix.py", line 53, in get_config
libraries = [ dequote(i[2:]) for i in libs if i.startswith(compiler_flag("l")) ]
File "setup_posix.py", line 8, in dequote
if s[0] in "\"'" and s[0] == s[-1]:
IndexError: string index out of range
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
这个问题,在此篇文章有提到,但按照他的方法并不能解决,遂继续谷歌
最终解决办法
https://www.cnblogs.com/LordNeo/p/9687832.html
参考这篇文章执行了重新安装了 mysql-connector-c ,修改了mysql的配置文件;
执行了brew info openssl,得到
(flask-demo) ➜ homebrew-core git:(master) brew info openssl
openssl: stable 1.0.2t (bottled) [keg-only]
SSL/TLS cryptography library
https://openssl.org/
/usr/local/Cellar/openssl/1.0.2t (1,795 files, 12.0MB)
Poured from bottle on 2019-10-30 at 18:26:15
From: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git/Formula/openssl.rb
==> Caveats
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), place .pem files in
/usr/local/etc/openssl/certs
and run
/usr/local/opt/openssl/bin/c_rehash
openssl is keg-only, which means it was not symlinked into /usr/local,
because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.
If you need to have openssl first in your PATH run:
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.zshrc
For compilers to find openssl you may need to set:
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
For pkg-config to find openssl you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"
随后执行了提示里的 echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.zshrc
同时,把下面语句加入了 bash_profile 并source bash_profile。
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
再使用 pip安装,成功了……
后记
都2019年了,Mac/Linux安装这个包还要这么心累………………
Mac安装MySQL-python的血泪史的更多相关文章
- mac安装mysql及终端操作mysql与pycharm的数据库可视化
一.Mac安装mysql 首先下载mysql,地址:https://dev.mysql.com/downloads/mysql/ 然后已知安装就好了,会出现让你记住密码的提示,然后就安装好了.... ...
- mac安装mysql数据库及配置环境变量
mac安装mysql数据库及配置环境变量 mac安装mysql数据库及配置环境变量 原文文链接:https://blog.csdn.net/qq_36004521/article/details/80 ...
- mac 安装mysql + 修改root用户密码 + 及报Access denied for user 'root'@'localhost' (using password:YES)解决办法
1.下载MySQL 到mysql的官网http://dev.mysql.com/downloads/mysql/然后在页面中会看到“MySQL Community Server”下方有一个“downl ...
- Mac 安装 MySQL
在 Mac 下用 Homebrew 安装 MySQL, 网上的教程倒是很多,不过大多数都很默契地雷同.如果稍有点定制要求,就无从下手了. 我先也不免俗,从基本的开始: 一.首先安装 Homebrew ...
- Install MySQL on Mac OS X——MAC安装MySQL
很多关于如何安装MySQL的教程已经过时了,或者比必须的步骤复杂得多.这篇教程将展示如何安装MySQL,启动MySQL,以root用户进入MySQL,以及创建删除退出数据库. Step 1: 下载My ...
- Mac安装Mysql无法登录
Mac安装的Mysql5.7.10 执行mysql -u root -p 就要求输入密码,但是新安装是没密码的.然后就会报错. ERROR 1045 (28000): Access denied fo ...
- mac 安装mysql 修改密码
我草!!! 上网查资料,安装mysql,一大推废话,简直就是他妈的瞎扯淡,真是能他妈的瞎编,草! 为了不让后面的同学看到那些狗屁不通的资料,我把自己安装mysql的步骤,以及修改mysql密码的方法梳 ...
- mac安装mysql的两种方法(含配置)
1.使用安装包安装mysql 双击打开安装文件 双击pkg文件安装 一路向下,记得保存最后弹出框中的密码(它是你mysql root账号的密码) 正常情况下,安装成功. 此时只是安装成功,但还需要额外 ...
- mac安装mysql及workbench
安装mysql 登录MySQL网站 打开网站Download MySQL Community Server,选择下方的dmg文件下载 点击download,此处为8.0.11版本 然后选择no tha ...
- mac 安装 mysql 配置
前言:下面主要介绍2种安装方法以及后续的配置,希望对大家有帮助.(推荐通过安装包的形式安装) 1. 使用安装包安装 mysql 双击打开安装文件 双击pkg文件安装 一 ...
随机推荐
- 【异常】微博生成短链异常{"request":"/2/short_url/shorten.json","error_code":"10014","error":"Insufficient app permissions!"}
一.之前的调用方式 这种方式用了大约有一年时间,之前没有问题,但是2019-8-28号突然不行了,可能是由于微博对该接口的调用做了限制.不允许通过传递source参数的方式进行请求 该接口微博API文 ...
- LVSDR模型与持久连接
LVS之DR模型以及持久连接 LVS的简单介绍 linux virtual server 简单来讲lvs是一段内核代码 类似于netfilter本身是一框架但不提供任何功能,但是在这框架上提供了能够根 ...
- python3 networkx
一.networkx 1.用于图论和复杂网络 2.官网:http://networkx.github.io/ 3.networkx常常结合numpy等数据处理相关的库一起使用,通过matplot来可视 ...
- bat echo输出内容指定颜色
bat echo 输出内容为不同的颜色 先看代码: @echo off SETLOCAL EnableDelayedExpansion for /F "tokens=1,2 delims=# ...
- 闲谈关于discuz内核缓存机制
Discuz! 缓存 Discuz! X2.5 的 config_global.php 中有这样一行代码 $_config['cache']['type'] = 'sql'; 这就是 Discuz! ...
- python基础语法1 用户交互,基本数据类型,格式化输出,运算符
与用户交互: 输入: python2: input一定要声明你输入的类型 >>> input(">>:") >>:sean Traceba ...
- Fiddler实现篡改接口请求和返回数据
步骤如下: 点击rules->Automatic Breakpoints,在这个选项下,我们可以看到三个可选项: Before Requests:在请求发出前拦截请求: After Reques ...
- cf1158A-The Party and Sweets - (贪心+思维)
题意:有n个男孩,m个女孩,每个男孩给每个女孩一堆糖果.b数组表示每个男孩给出的最少糖果数,g数组表示每个女孩子收到的最大糖果数.求所有男孩给出的最小糖果总数. 解题: 先对b数组和g数组从小到大排序 ...
- 学习:STL_deque容器
deque容器: 功能:双端数组,可以对头端进行插入删除操作 deque与vector区别: 1.vector对于头部的插入删除效率低,数据量越大,效率越低 2.deque相对而言,对头部的插入删除速 ...
- Redis之eval+lua实现初步
目录 目录 1 1. 前言 1 2. 执行方式 1 3. 执行过程 3 4. 使用原则 3 1. 前言 Redis的实现保证eval的执行是原子的,即使eval执行的lua超时,Redis也不会自动终 ...