Skip to main content
 首页 » 编程设计

python之如何验证 python 是否使用 Open SSL Libraries 编译

2025年05月04日15java哥

目标

验证 Python 安装是否已使用 OpenSSL 库进行编译。连接器文档表明这是一个 requirement for SSL support :

"verify that your Python installation has been compiled using the OpenSSL libraries"

更新:在这种情况下,目标操作系统是具有 Python 2.7 的 Raspbian Jessie

问题

是否可以执行命令行测试以确认使用 OpenSSL 库进行编译?

请您参考如下方法:

尝试导入 ssl 模块可能就足够了:

try: 
    import ssl 
except ImportError: 
    print('No SSL') 

在命令行上:

$ python -c 'import ssl' >/dev/null 2>&1 && echo 'installed' || echo 'not installed'