今天繼續(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总滩,需要安裝。我一開(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了嚎!