在Mac OS 10.14.1上安装MySQL-Python时出现问题

时间:2018-11-24 22:26:00

标签: pip mysql-python macos-mojave

我最近升级到Mac OS Mojave,现在无法安装MySQL-Python:

pip install MySQL-Python

...
clang -bundle -undefined dynamic_lookup build/temp.macosx-10.13-x86_64-2.7/_mysql.o -L/usr/local/opt/mysql-client/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.13-x86_64-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 'clang' failed with exit status 1

堆栈跟踪显示未找到“ ssl”库。我不确定这是什么意思,因为我已经安装了最新的XCode和OpenSSL。任何建议表示赞赏。

2 个答案:

答案 0 :(得分:2)

我在MacOS 10.14上遇到了同样的问题,并且可以通过以下步骤解决它:

/usr/local的权限更改为allow Homebrew to create links

sudo chown -R $(whoami) $(brew --prefix)/*

现在已修复权限,重新安装openssl:

brew reinstall openssl

运行以下两个命令以允许编译器找到openssl:

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

然后,再次尝试安装MySQL-Python:

pip install MySQL-Python

答案 1 :(得分:0)

  

更改/ usr / local的权限以允许Homebrew创建链接:

sudo chown -R $(whoami) $(brew --prefix)/*
     

现在已修复权限,重新安装openssl:

brew reinstall openssl
     

运行以下两个命令以允许编译器找到openssl:

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

然后,再次尝试安装MySQL-Python:

pip install MySQL-Python

它适用于具有python2.7 / Django 1.9.8的Mac 10.14.2和具有mysql-clinet的mysql-server 8;