ImportError: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'OpenSSL 1.0.2k-fips

问题

在 jenkins 结点中运行脚本显示:

ImportError: urllib3 v2 only supports OpenSSL 1.1.1+, currently the ‘ssl’ module is compiled with 'OpenSSL 1.0.2k-fips

原因

错误的原因依然是 urllib3 版本 2.x 和当前系统的 OpenSSL 版本不兼容。你正在使用 OpenSSL 1.0.2k 版本,而 urllib3 v2.x 版本要求 OpenSSL 至少为 1.1.1。

解决

requirements.txt 中指定兼容的依赖: 如果你有其他团队成员或在 CI 环境中运行测试,建议在 requirements.txt 文件中指定兼容的 urllib3 版本,确保环境一致性:

requests==2.x.x
urllib3<2