python mac下安裝 MySQLdb模塊的坑 library not found for -lssl

今天繼續(xù)安裝mysql模塊,參考以往的思路,繼續(xù)度娘,下載mysqldb的包,解壓,在里面執(zhí)行python setup.py install

結(jié)果總是那么不順利(否則也不會(huì)有這篇文章了),關(guān)于要配置mysql_config那個(gè)就不說(shuō)了,下面劃重點(diǎn)

出現(xiàn)的問(wèn)題:

cc -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -Wl,-F. build/temp.macosx-10.11-intel-2.7/_mysql.o -L/usr/local/Cellar/mysql/5.7.14/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.11-intel-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 'cc' failed with exit status 1

碰到這個(gè)問(wèn)題,我以為只是某個(gè)lssl包沒(méi)有,然后傻乎乎的去brew search lssl,發(fā)現(xiàn)沒(méi)有,然后去問(wèn)度娘,找到了一篇關(guān)于 ld: library not found for -lssl 的,

http://stackoverflow.com/questions/19652877/installing-saltstack-at-os-x-error-ld-library-not-found-for-lssl

這里有個(gè)哥們說(shuō)了

缺少libssl

缺少libssl,需要安裝。我一開(kāi)始也是懷著際動(dòng)的心情去 brew search libssl ,沒(méi)有!懵逼一下,

然后再問(wèn)了下度娘libssl,發(fā)現(xiàn)它是openssl里的,而我本地的openssl已經(jīng)有安裝。于是回過(guò)頭來(lái)繼續(xù)看發(fā)現(xiàn)有一句重點(diǎn)我沒(méi)詳看:

You didn't include the link to the tutorial you are using at the top of your question. The link you created would not work, you need to link to the directory that contains either libssl.a or libssl.dylib. Better yet, change that -L parameter to search the correct location of your ssl library.

安裝的時(shí)候沒(méi)有引用這個(gè)鏈接,然后繼續(xù)訪問(wèn)下面那個(gè)哥們留的那個(gè)地址,關(guān)于類似問(wèn)題的解決方案:

http://stackoverflow.com/questions/26288042/error-installing-psycopg2-library-not-found-for-lssl/39244687#39244687

這篇文章里有類似這樣的話

you could also try to link against brew's openssl:

env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib"pip install psycopg2

到這里,我心里大概有點(diǎn)明白了,我執(zhí)行安裝的時(shí)候,需要把openssl/lib的路徑鏈接上去,我去找了下openssl路徑,確實(shí)是/usr/local/opt/openssl/lib/,而且里面確實(shí)有 libssl.a和libssl.dylib兩個(gè)文件。

然后 執(zhí)行

env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" python setup.py install

安裝成功!

這個(gè)問(wèn)題困擾了我一中午,有時(shí)候還是得看老外說(shuō)的(英語(yǔ)不好的表示很心塞)。感謝stackoverflow!

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容