Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None))

Tags:

python

pip

I'm trying to do pip install --upgrade pip and keep
getting this error:

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

Also, I can't install any new package due to this error.
I tried to reinstall Pycharm but no luck there.
I tried some other suggested solutions online - still no luck.
I understand it has something to do with Proxy but I am not familiar with it, Anyone?

like image 868
Omri Avatar asked Dec 15 '25 05:12

Omri


2 Answers

Try appending your build command with --network=host
Eg : docker build -t cointainer_name . --network=host

If you use the host network mode for a container, that container’s network stack is not isolated from the 
Docker host (the container shares the host’s networking namespace), and the container does not 
get its own IP-address allocated. 
For instance, if you run a container which binds to port 80 and you use host 
networking, the container’s application is available on port 80 on the host’s IP address.

Check here for more details

like image 123
cryptoKTM Avatar answered Dec 16 '25 21:12

cryptoKTM


TL;DR for Windows, this works for me.

  1. Windows + I (to open Settings).
  2. Choose Network & Internet
  3. Choose Proxy
  4. Check Manual proxy setup to be in the Off-position

---all starts to work here already---

  1. Note: Automatically detect settings switched to On or to Off cause no influence for me (all still continue to work as it started to work after 4.).

Pre-story

I had the same error. Can't install libs by pip, by pipenv, by anaconda, by PyCharm. Then I checked Proxy setting (Windows 11 OS) and noticed I have some Manual proxy setup defined. When disable it - the problem was fixed.

The problem began very spontaneously: I did some python-work, did some installations (maybe some pithon-module with pipenv like notebook or jupyter-lab, cygwin tool etc.) and then installing/updating of the python-modules was crashed. Maybe some installations changed the proxy-parameters? I don't know.
Python re-installing didn't help.

Errors examples

For example, anaconda error while installing/updating looks like:

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'

Pip error while installing/updating looks like:

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.', 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/
like image 32
dmitmatveev Avatar answered Dec 16 '25 21:12

dmitmatveev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!