使用 pip 安装 SSLError

yan*_*nnm 10 python windows django ssl

我正在尝试在 windows 10 上安装 Django。

无论我尝试在 cmd 上使用 pip 安装什么,我都会收到这些错误

Collecting django
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1056)'))': /simple/django/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1056)'))': /simple/django/
  Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1056)'))': /simple/django/
  Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1056)'))': /simple/django/
  Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1056)'))': /simple/django/
  Could not fetch URL https://pypi.org/simple/django/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/django/ (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1056)'))) - skipping
  Could not find a version that satisfies the requirement django (from versions: )
No matching distribution found for django
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(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1056)'))) - skipping
Run Code Online (Sandbox Code Playgroud)

我已经从其他问题中尝试了很多东西,但都没有奏效。

pip install --upgrade pip --trusted-host pypi.org --trusted-host files.pythonhosted.org

pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org django

小智 23

正确设置我的代理也为我解决了这个问题。问题是我对 HTTPS_PROXY 和 https_proxy 环境变量使用了 http s协议。

用:

HTTPS_PROXY="http://username:password@proxy.example.com:8080"
https_proxy="http://username:password@proxy.example.com:8080"
Run Code Online (Sandbox Code Playgroud)

不使用:

HTTPS_PROXY="https://username:password@proxy.example.com:8080"
https_proxy="https://username:password@proxy.example.com:8080"
Run Code Online (Sandbox Code Playgroud)

  • 7 年后..仍然保持良好..Python 3.9.4 (3认同)
  • 以防万一有人来到这里,在 powershell 中,这对我有用: ```$env:HTTPS_PROXY = "http://proxy:port" $env:https_proxy = "http://proxy:port"``` (3认同)

Mar*_*ark 12

我的 pip 工作正常(Win7,python 3.8.6),直到我将 pip 从版本 20.2.1 升级到 20.3.1,之后我也收到了 SSL: WRONG_VERSION_NUMBER 错误。这是可重现的,我卸载并重新安装了几次以确认。

解决方案(好吧,变通方法):不要将 pip 升级到 20.3.1。

注意:pip 20.3.1 在我的 Win10/python 3.9.1 环境中工作正常。


yan*_*nnm 6

我问了一位同事,他自动知道该做什么。我只需要设置代理变量:“set https_proxy= http://username:password@proxy.example.com:8080 ”“set http_proxy= http://username:password@proxy.example.com:8080 ”和有用