【问题标题】:Python “SSLError(”Can't connect to HTTPS URL because the SSL module is not available.“)': /simple/docutils/”Python“SSLError(”无法连接到 HTTPS URL,因为 SSL 模块不可用。“)':/simple/docutils/”
【发布时间】:2020-08-01 08:41:55
【问题描述】:

问题

  • 无论我尝试使用 pip 从终端安装什么,都会收到此错误消息
  • 我之前可能已经安装并完全删除了 homebrew (macOS 10.12),但我不知道如何解决这个问题
  • Django 3.0 应用运行良好

我尝试运行的安装(所有情况都相同的错误消息)

pip install -r requirements.txt
pip install django-storages
pip install ssl

错误信息

WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/django-storages/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/django-storages/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/django-storages/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/django-storages/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/django-storages/
Could not fetch URL https://pypi.org/simple/django-storages/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/django-storages/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
ERROR: Could not find a version that satisfies the requirement django-storages (from versions: none)
ERROR: No matching distribution found for django-storages
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping

尝试过的解决方案

【问题讨论】:

  • 你试过this吗?好像是图书馆的问题。除此之外,请尝试重新安装 Python
  • 我不知道为什么我的 cmets 被删除了,所以我再重复一遍:导入 _ssl 模块时出现错误,所以要么你的虚拟环境(如果你使用一个)甚至你的 python 安装很糟糕你可以通过尝试在虚拟环境之外导入_ssl 来检查。因此问题又来了——你是如何安装 python 的?你是如何创建虚拟环境的?
  • 另一件事——不要做pip install ssl,它是标准库的一部分,安装第三方ssl在最好的情况下不会带来任何东西,在最坏的情况下会导致更多的错误。跨度>
  • 我不得不删除我的问题,因为我已经用一些敏感信息更新了我的问题,抱歉。 @hoefling 只是发布这个,我接受你的回答stackoverflow.com/a/29969862/10270590

标签: python django ssl pip homebrew


【解决方案1】:

https://stackoverflow.com/a/29969862/10270590

转到您的 virtualenv 目录(但不要运行 workon):

cd ~/.virtualenv/name_of_broken_venv

现在删除这些文件:

rm -rf .Python bin/python* lib/python2.7/* include/python2.7

然后重建你的venv,运行:

virtualenv .
pip install -r requirements.txt

【讨论】:

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