Python "SSLError("无法连接到 HTTPS URL,因为 SSL 模块不可用。



问题

  • 无论我试图从带有pip的终端安装什么,我都会收到此错误消息
  • 我以前可能安装并完全删除了自制软件(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

尝试过的解决方案

  • https://stackoverflow.com/a/59280089/10270590
  • pip-TLS/SSL,但是Python中的SSL模块不存在问题
  • pip配置有需要TLS/SSL的位置,但是Python中的SSL模块不可用
  • @锄https://stackoverflow.com/users/2650249/hoefling建议运行:python -c "import _ssl"
    • 结果:dyld: Library not loaded: @executable_path/../.Python Referenced from: /Users/..../django_app_mainfolder/ven/bin/python Reason: image not found Abort trap: 6
    • 推荐的解决方案:Virtualenvs中的断开引用
    • 我在看这里的主要答案,但我不知道发生了什么https://stackoverflow.com/a/25947333/10270590=这就是答案的由来
    • 未工作-https://stackoverflow.com/a/23660033/10270590
    • 不可用-我现在不使用酿造-https://stackoverflow.com/a/51145074/10270590

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

最新更新