2016-11-14 42 views
7

我在安裝mysql-python時遇到了問題。創建一個新的virtualenv和安裝MySQL-python的時候......這裏的錯誤消息:安裝mysql-python時出錯:找不到-lssl的庫

(env)$ pip install mysql-python 
Collecting mysql-python 
... 

clang -bundle -undefined dynamic_lookup -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk build/temp.macosx-10.12-x86_64-2.7/_mysql.o -L/usr /local/Cellar/mysql/5.7.16/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.12-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 

使用自制軟件,我已經安裝:

已經嘗試t brew link但釀造拒絕這樣做。

操作系統是MacOS Sierra。

任何人都可以幫忙嗎?謝謝!

回答

9

這些步驟解決了這個問題:

brew uninstall mysql 
brew install mysql-connector-c 
pip install mysql-python 
brew unlink mysql-connector-c 
brew install mysql 

在這裏找到https://stackoverflow.com/a/25920020/576192

不知道這是正確的方式回答,但這是我如何設法解決這個問題。

+2

在'pip install mysql-python'中沒有爲我工作 – Jonny

5

我終於能夠通過

xcode-select --install

來解決它,我確信我已經這樣做了......但是顯然我沒有。絕對值得一試!

1

爲我工作做這個

$ brew uninstall mysql 
$ brew install mysql-connector-c 
$ brew unlink mysql-connector-c 
$ brew install mysql 
$ pip install mysql-python 

這是上面的配方的稍微改變版本(注:pip install末)

1

如果你想安裝mysql-python,我建議你改爲安裝mysqlclient。這兩個模塊的作者是相同的。到目前爲止,作者都轉向保持mysqlclientmysqlclient支持Python 2和Python 3.您可以使用相同的代碼,如mysql-python。 Blew是我的安裝解決方案。

$ brew info openssl 
$ brew unlink mysql-connector-c 
$ brew install mysql 
$ brew link --overwrite mysql-connector-c 
$ pip install mysqlclient 

如果在pip install mysqlclient之前有錯誤。請根據methane's answer進行修復。 並再次運行pip install mysqlclient

1

您可以顯式設置ssl庫路徑。

LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysqlclient