Python:如何判断我的Python是否有SSL?
如何判断源代码构建的python是否启用了SSL?或者Python:如何判断我的Python是否有SSL?,python,ssl,Python,Ssl,如何判断源代码构建的python是否启用了SSL?或者 在运行configure之后,但在编译之前(最佳) 编译后,当我可以运行python时 背景: 填充裸linux机箱的脚本 先决条件是安装openssl,以便Python可以使用https 正在尝试检测是否未满足此前提条件 如果您只想知道是否安装了openssl,您可以解析openssl版本的输出: $ openssl version OpenSSL 1.0.2g-fips 1 Mar 2016 您可以从version获取,例如,
- 在运行configure之后,但在编译之前(最佳)
- 编译后,当我可以运行python时
- 填充裸linux机箱的脚本
- 先决条件是安装openssl,以便Python可以使用https
- 正在尝试检测是否未满足此前提条件
openssl
,您可以解析openssl版本的输出:
$ openssl version
OpenSSL 1.0.2g-fips 1 Mar 2016
您可以从version
获取,例如,其存储目录:
$ openssl version -d
OPENSSLDIR: "/usr/lib/ssl"
就Python而言,我不确定在运行configure(可能检查config.log
?)之前如何判断,但一旦安装了Python;只需解析ssl.OPENSSL\u VERSION
的输出,如下所示:
$ python -c "import ssl; print(ssl.OPENSSL_VERSION)"
OpenSSL 1.0.2g-fips 1 Mar 2016
有关更多信息,请使用sysconfig
模块,例如:
$ python -c "import sysconfig; print(sysconfig.get_config_var('CONFIG_ARGS'))"
'--enable-shared' '--prefix=/usr' '--enable-ipv6' '--enable-unicode=ucs4' '--with-dbmliborder=bdb:gdbm' '--with-system-expat' '--with-computed-gotos' '--with-system-ffi' '--with-fpectl' 'CC=x86_64-linux-gnu-gcc' 'CFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security ' 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro'
//,python-c“导入ssl;打印(ssl.OPENSSL\u版本)”
工作得很好。我知道我的python
有SSL,但是python3-c“导入SSL;打印(SSL.OPENSSL\u版本)”
的结果是ModuleNotFoundError
。谢谢,伯翰