简体   繁体   English

无法 pip 安装任何东西,出现“无法连接到代理”错误

[英]Cannot pip install anything, get 'Cannot connect to proxy' error

Other solutions suggested turning off proxies and altering the system32 'hosts' file.其他解决方案建议关闭代理并更改 system32 'hosts' 文件。 I can't do either as I am using a company computer and need the former to connect to the company network and I don't have admin privileges for the latter.我不能这样做,因为我使用的是公司计算机,需要前者连接到公司网络,而我没有后者的管理员权限。 The error:错误:

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', timeout('_ssl.c:1112: The handshake operation timed out'))': /simple/selenium/警告:重试(重试(总计 = 4,连接 = 无,读取 = 无,重定向 = 无,状态 = 无))在连接被 'ProxyError('无法连接到代理。',超时('_ssl.c:1112 : 握手操作超时'))': /simple/selenium/

Anyone have this experience?有没有人有这种经历? Specifically working for solutions that would work on a company computer专门适用于可在公司计算机上运行的解决方案

Resolution: it is likely that you've set up your proxies like this...解决方案:您可能已经像这样设置了代理...

proxies = {
  "http": "http://myproxy.org",
  "https": "https://myproxy.org",
}

Using this setup, you're trying to connect to the proxy using HTTP for HTTP requests, and using HTTPS for HTTPS requests.使用此设置,您尝试将 HTTP 用于 HTTP 请求并使用 HTTPS 用于 HTTPS 请求连接到代理。

But if you get the error above, it is likely that your proxy doesn't support connecting via HTTPS.但是,如果您收到上述错误,则可能是您的代理不支持通过 HTTPS 连接。 Don't worry: that's a common gotcha.别担心:这是一个常见的问题。

Change the scheme of your HTTPS proxy to http://... instead of https://...:将 HTTPS 代理的方案更改为 http://... 而不是 https://...:

proxies = {
  "http": "http://myproxy.org",
  "https": "http://myproxy.org",
}

This can be simplified to:这可以简化为:

proxies = "http://myproxy.org"

For more information, see Proxies: FORWARD vs TUNNEL .有关更多信息,请参阅代理:转发与隧道

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM