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/[email protected]/bin:/usr/local/opt/[email protected]/bin:$PATH"‘ >> ~/.bash_profile
echo ‘export LDFLAGS="-L/usr/local/opt/[email protected]/lib -L/usr/local/opt/[email protected]/lib/"‘ >> ~/.bash_profile
echo ‘export CPPFLAGS="-I/usr/local/opt/[email protected]/include -I/usr/local/opt/[email protected]/include"‘ >> ~/.bash_profile
echo ‘export PKG_CONFIG_PATH="/usr/local/opt/[email protected]/lib/pkgconfig"‘ >> ~/.bash_profile
source ~/.bash_profile
再执行 pip install MySQL-python
OK
原文地址:https://blog.51cto.com/784687488/2386161
时间: 2024-10-09 01:55:52