Python 警告:重试(重试(总计=4,连接=无,读取=无,重定向=无,状态=无))

Omr*_*mri 11 python

我正在尝试执行pip install --upgrade pip并不断
收到此错误:

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnection
Error('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x0000026F50B448C8>: Failed to establish a new connection: [WinError 10061] No connection could be made
 because the target machine actively refused it'))': /simple/pytest/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnection
Error('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x0000026F50B59148>: Failed to establish a new connection: [WinError 10061] No connection could be made
 because the target machine actively refused it'))': /simple/pytest/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnection
Error('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x0000026F50B596C8>: Failed to establish a new connection: [WinError 10061] No connection could be made
 because the target machine actively refused it'))': /simple/pytest/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnection
Error('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x0000026F50B595C8>: Failed to establish a new connection: [WinError 10061] No connection could be made
 because the target machine actively refused it'))': /simple/pytest/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnection
Error('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x0000026F50B5F2C8>: Failed to establish a new connection: [WinError 10061] No connection could be made
 because the target machine actively refused it'))': /simple/pytest/
ERROR: Could not find a version that satisfies the requirement pytest
ERROR: No matching distribution found for pytest
Run Code Online (Sandbox Code Playgroud)

另外,由于此错误,我无法安装任何新软件包。
我尝试重新安装 Pycharm 但没有成功。
我在网上尝试了一些其他建议的解决方案 - 仍然没有运气。
我知道它与 Proxy 有关,但我不熟悉它,有人吗?

cry*_*KTM 11

尝试使用--network=host附加构建命令
\nEg :docker build -t cointainer_name . --network=host

\n
If you use the host network mode for a container, that container\xe2\x80\x99s network stack is not isolated from the \nDocker host (the container shares the host\xe2\x80\x99s networking namespace), and the container does not \nget its own IP-address allocated. \nFor instance, if you run a container which binds to port 80 and you use host \nnetworking, the container\xe2\x80\x99s application is available on port 80 on the host\xe2\x80\x99s IP address.\n
Run Code Online (Sandbox Code Playgroud)\n

检查这里了解更多详情

\n


小智 5

TL;DR 对于 Windows,这对我有用。

  1. Windows+ I(打开“设置”)。
  2. 选择Network & Internet
  3. 选择Proxy
  4. 检查Manual proxy setup是否处于Off- 位置

---一切都已经开始在这里工作了---

  1. 注:Automatically detect settings切换至On或 至Off对我没有影响(一切仍然继续工作,因为它在4.之后开始工作)。

前言

我有同样的错误。无法安装由pip、 由pipenv、 由 anaconda 、 由 PyCharm 提供的库。然后我检查了Proxy设置(Windows 11 操作系统)并注意到我有一些Manual proxy setup定义。当禁用它时 - 问题得到解决。

问题非常自发地开始:我做了一些 python 工作,做了一些安装(可能是一些带有pipenv笔记本或 jupyter-lab、cygwin工具等的 Pithon 模块),然后安装/更新 python 模块崩溃了。也许某些安装更改了代理参数?我不知道。
Python 重新安装没有帮助。

错误示例

例如,安装/更新时的 anaconda 错误如下所示:

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/main/win-64/current_repodata.json>
Elapsed: -

An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.

If your current network has https://www.anaconda.com blocked, please file
a support request with your network engineering team.

'https://repo.anaconda.com/pkgs/main/win-64'
Run Code Online (Sandbox Code Playgroud)

安装/更新时的 Pip 错误如下所示:

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/main/win-64/current_repodata.json>
Elapsed: -

An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.

If your current network has https://www.anaconda.com blocked, please file
a support request with your network engineering team.

'https://repo.anaconda.com/pkgs/main/win-64'
Run Code Online (Sandbox Code Playgroud)
>>>
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', FileNotFoundError(2, 'No such file or directory'))': /simple/pip/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', FileNotFoundError(2, 'No such file or directory'))': /simple/pip/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', FileNotFoundError(2, 'No such file or directory'))': /simple/pip/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', FileNotFoundError(2, 'No such file or directory'))': /simple/pip/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', FileNotFoundError(2, 'No such file or directory'))': /simple/pip/
Run Code Online (Sandbox Code Playgroud)