"pip install mysql-python"安装失败,出现"ld: library not found for -lssl"错误提示。

5

运行 pip install mysql-python 失败并显示以下错误:

cc -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -Wl,-F. build/temp.macosx-10.12-intel-2.7/_mysql.o -L/usr/local/Cellar/mysql/5.7.13/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.12-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

我想这可能是一些SSL库没有正确安装。有什么建议吗?
1个回答

4

您需要查找您是否拥有openssl库以及它们的位置:

sudo find / -name "openssl"

我在这里找到了它:
ls -lA /usr/local/opt/openssl/
total 1080
drwxr-xr-x   3 _  admin     102 May 25 14:55 .bottle
drwxr-xr-x   3 _  admin     102 May 25 14:55 .brew
-rw-r--r--   1 _  admin  497920 Jul 16 16:36 CHANGES
-rw-r--r--   1 _  admin     772 Jul 16 16:36 INSTALL_RECEIPT.json
-rw-r--r--   1 _  admin    6281 May 25 14:55 LICENSE
-rw-r--r--   1 _  admin   34649 May 25 14:55 NEWS
-rw-r--r--   1 _  admin    3282 May 25 14:55 README
drwxr-xr-x   4 _  admin     136 Jul 16 16:36 bin
drwxr-xr-x   3 _  admin     102 May 25 14:55 include
drwxr-xr-x  10 _  admin     340 May 25 14:55 lib
drwxr-xr-x   3 _  admin     102 May 25 14:55 share

安装Python软件包,您需要使用以下命令:

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

或者运行 brew info openssl 命令,它会报告:"为了让编译器找到这个软件,你可能需要设置: LDFLAGS: -L/usr/local/opt/openssl/lib CPPFLAGS: -I/usr/local/opt/openssl/include" - Carl G

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接