python mac下安装 MySQLdb模块的坑 library not found for -lssl

今天继续安装mysql模块,参考以往的思路,继续度娘,下载mysqldb的包,解压,在里面执行python setup.py install

结果总是那么不顺利(否则也不会有这篇文章了),关于要配置mysql_config那个就不说了,下面划重点

出现的问题:

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

碰到这个问题,我以为只是某个lssl包没有,然后傻乎乎的去brew search lssl,发现没有,然后去问度娘,找到了一篇关于 ld: library not found for -lssl 的,

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

这里有个哥们说了

缺少libssl

缺少libssl,需要安装。我一开始也是怀着际动的心情去 brew search libssl ,没有!懵逼一下,

然后再问了下度娘libssl,发现它是openssl里的,而我本地的openssl已经有安装。于是回过头来继续看发现有一句重点我没详看:

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.

安装的时候没有引用这个链接,然后继续访问下面那个哥们留的那个地址,关于类似问题的解决方案:

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

到这里,我心里大概有点明白了,我执行安装的时候,需要把openssl/lib的路径链接上去,我去找了下openssl路径,确实是/usr/local/opt/openssl/lib/,而且里面确实有 libssl.a和libssl.dylib两个文件。

然后 执行

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

安装成功!

这个问题困扰了我一中午,有时候还是得看老外说的(英语不好的表示很心塞)。感谢stackoverflow!

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容