我正在尝试在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
我从其他问题中尝试了很多方法,但是没有一个起作用。
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
答案 0 :(得分:15)
正确设置我的代理也为我解决了这个问题。问题是我对 HTTPS_PROXY 和 https_proxy 环境变量使用了 https 协议。
使用:
HTTPS_PROXY=http://username:password@proxy.example.com:8080"
https_proxy=http://username:password@proxy.example.com:8080"
请勿使用:
HTTPS_PROXY=https://username:password@proxy.example.com:8080"
https_proxy=https://username:password@proxy.example.com:8080"
答案 1 :(得分:3)
我的pip正常运行(Win7,python 3.8.6),直到我将pip从20.2.1版本升级到20.3.1,之后我还收到了SSL:WRONG_VERSION_NUMBER错误。这是可复制的,我卸载并重新安装了几次以确认。
解决方案(很好,解决方法):不要将点升级到20.3.1。
注意:在我的Win10 / python 3.9.1环境中,pip 20.3.1正常工作。
答案 2 :(得分:1)
检查您的代理设置。您可以使用此命令
wstat
答案 3 :(得分:0)
我问一个同事,他自动知道该怎么做。我只需要设置代理变量: “设置https_proxy = http://username:password@proxy.example.com:8080” “设置http_proxy = http://username:password@proxy.example.com:8080” 而且有效
答案 4 :(得分:0)
对我来说,它是系统代理,据我所知,当 pip 想要查询不安全的 <?php
tg("Olá");
function tg($text) {
$data = ['chat_id' => '@xxx', 'disable_web_page_preview' => true, 'parse_mode' => 'HTML', 'text' => $text];
file_get_contents('https://api.telegram.org/xx:xxxx-yyy/sendMessage?'.http_build_query($data));
}
索引并且 pip 默认仅查询 SSL 安全索引时,会使用 trusted-host
标志。
答案 5 :(得分:0)
如果有人仍然遇到此问题,请尝试查找并删除 OpenSSL(操作系统级安装),如果它已安装在您的系统中。
就我而言,我很久以前在 Windows 10 上安装了 openssl(用于其他一些开发任务)却忘记了,这是罪魁祸首。我卸载了它,它解决了问题