运维开发网

MacOS Mojave 10.14.4 安装 MySQLdb 报错处理

运维开发网 https://www.qedev.com 2020-03-19 10:16 出处:51CTO 作者:FanoLi
MacOS Mojave 10.14.4 安装 MySQLdb 报错问题解决

MacOS Mojave 10.14.4 上安装 MySQL-python 恶心到吐,以前 MacOS series 版本时安装过,但没有这么痛苦。为以后不再被恶心到,还是记录一下吧。

我们安装 MySQL-python 之前应该都已经安装过 mysql 了,这里就不记录了。

执行 pip install MySQL-python

第一种报错:

_mysql.c:44:10: fatal error: 'my_config.h' file not found

#include "my_config.h"

^~~~~

1 error generated.

error: command 'cc' failed with exit status 1

解决方法:

brew install mysql-connector-c

上面的问题解决了,会再报第二种错:

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

解决方法:

echo 'export PATH="/usr/local/opt/mysql@5.7/bin:/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.bash_profile
echo 'export LDFLAGS="-L/usr/local/opt/mysql@5.7/lib -L/usr/local/opt/openssl@1.1/lib/"' >> ~/.bash_profile
echo 'export CPPFLAGS="-I/usr/local/opt/mysql@5.7/include -I/usr/local/opt/openssl@1.1/include"' >> ~/.bash_profile
echo 'export PKG_CONFIG_PATH="/usr/local/opt/mysql@5.7/lib/pkgconfig"' >> ~/.bash_profile
source ~/.bash_profile

再执行 pip install MySQL-python

OK

0

精彩评论

暂无评论...
验证码 换一张
取 消