【问题标题】:Requests (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.") On Linux请求(由 SSLError 引起(“无法连接到 HTTPS URL,因为 SSL 模块不可用。”)在 Linux 上
【发布时间】:2020-06-06 16:36:10
【问题描述】:

这个问题已经回答here,但适用于 Windows 用户。我在 Anaconda 环境下的第 3 方应用程序上的 Linux 机器上收到此错误。我在PATH env 中添加了以下路径:

<path>/anaconda2/lib
<path>/anaconda2/bin

但是当我跑步时:

import requests
requests.get("https://api.ipify.org")

我得到错误:

requests.exceptions.SSLError: HTTPSConnectionPool(host='api.ipify.org', 
port=443): Max retries exceeded with url: / (Caused by SSLError("Can't 
connect to HTTPS URL because the SSL module is not available."))

第 3 方应用程序和 conda shell 都在 PATH 环境中包含这些路径,但它仅适用于 shell。

【问题讨论】:

标签: python linux ssl python-requests anaconda


【解决方案1】:

错误消息显示“SSL 模块不可用”。 Requests 使用 openssl 作为其“SSL 模块”,因此请确保 openssl 已安装并正常工作。

第一次运行:

~$ conda list

您应该在输出中看到opensslpyopenssl

如果你不安装opensslpyopenssl

如果安装了 openssl 运行:

~$ openssl

如果你得到:

openssl: error while loading shared libraries: libcrypto.so.1.0.0: cannot enable executable stack as shared object requires: Invalid argument

使用上面的版本号运行

~$ sudo find / -name libcrypto.so.[your version] 

然后使用上述输出中的 libcrypto.so.[your version] 的路径:

~$ sudo execstack -c [path to]/libcrypto.so.[your version]

然后运行测试:

~$ openssl
OpenSSL>

您需要为所有环境执行此操作

【讨论】:

    【解决方案2】:

    原来我的python环境的lib-dynload目录中的_ssl.so模块被第3方软件中的_ssl.so模块覆盖,这是冲突的。所以我做了一个符号链接到我自己的模块。

    【讨论】:

      猜你喜欢
      • 2019-06-05
      • 2020-08-01
      • 2019-08-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-05
      • 1970-01-01
      • 2022-11-10
      相关资源
      最近更新 更多