MacOSMojave10.14.4安装MySQLdb报错处理

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

创新互联是一家专业提供香河企业网站建设,专注与成都网站建设、网站制作、H5技术、小程序制作等业务。10年已为香河众多企业、政府机构等服务。创新互联专业的建站公司优惠进行中。

我们安装 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


本文标题:MacOSMojave10.14.4安装MySQLdb报错处理
浏览路径:http://scyanting.com/article/psiodo.html