Pip ReadTimeoutError in Windows 10

天涯浪子 提交于 2021-01-28 12:57:04

问题


Fresh Python 3.7 64-bit install downloaded from their main website, working on Windows 10 Pro. Using PowerShell with Admin rights. Pip always throws ReadTimeoutError.

The command:

python -m pip -vvv install --upgrade pip

Returns the following:

Config variable 'Py_DEBUG' is unset, Python ABI tag may be incorrect Config variable 'WITH_PYMALLOC' is unset, Python ABI tag may be incorrect Created temporary directory: C:\Users\vbfal\AppData\Local\Temp\pip-ephem-wheel-cache-sotpqqgg Created temporary directory: C:\Users\vbfal\AppData\Local\Temp\pip-install-qqmlc7qa 1 location(s) to search for versions of pip: * https://pypi.org/simple/pip/ Getting page https://pypi.org/simple/pip/ Looking up "https://pypi.org/simple/pip/" in the cache No cache entry available Starting new HTTPS connection (1): pypi.org Incremented Retry for (url='/simple/pip/'): Retry(total=4, connect=None, read=None, redirect=None, status=None) Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/pip/ Starting new HTTPS connection (2): pypi.org Incremented Retry for (url='/simple/pip/'): Retry(total=3, connect=None, read=None, redirect=None, status=None) Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/pip/ Starting new HTTPS connection (3): pypi.org Incremented Retry for (url='/simple/pip/'): Retry(total=2, connect=None, read=None, redirect=None, status=None) Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/pip/ Starting new HTTPS connection (4): pypi.org Incremented Retry for (url='/simple/pip/'): Retry(total=1, connect=None, read=None, redirect=None, status=None) Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/pip/ Starting new HTTPS connection (5): pypi.org Incremented Retry for (url='/simple/pip/'): Retry(total=0, connect=None, read=None, redirect=None, status=None) Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/pip/ Starting new HTTPS connection (6): pypi.org Could not fetch URL https://pypi.org/simple/pip/: connection error: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")) - skipping Installed version (10.0.1) is most up-to-date (past versions: none) Requirement already up-to-date: pip in c:\program files\python37\lib\site-packages (10.0.1) Cleaning up... Config variable 'Py_DEBUG' is unset, Python ABI tag may be incorrect Config variable 'WITH_PYMALLOC' is unset, Python ABI tag may be incorrect 1 location(s) to search for versions of pip: * https://pypi.org/simple/pip/ Getting page https://pypi.org/simple/pip/ Looking up "https://pypi.org/simple/pip/" in the cache No cache entry available Starting new HTTPS connection (1): pypi.org Could not fetch URL https://pypi.org/simple/pip/: connection error: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=5)")) - skipping

I tried pinging pypi and it seemed ok:

Pinging pypi.org [151.101.64.223] with 32 bytes of data: Reply from 151.101.64.223: bytes=32 time=12ms TTL=57 Reply from 151.101.64.223: bytes=32 time=25ms TTL=57 Reply from 151.101.64.223: bytes=32 time=17ms TTL=57 Reply from 151.101.64.223: bytes=32 time=211ms TTL=57

Ping statistics for 151.101.64.223: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 12ms, Maximum = 211ms, Average = 66ms

At first curl to pypi.org seemed to hint at the root cause, returning:

curl : The request was aborted: Could not create SSL/TLS secure channel. At line:1 char:1 + curl pypi.org + ~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

I ran the following to force curl to use TLS 1.2:

[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"

Which then makes curl work (for the session only) returning status 200.

But alas, pip keeps throwing the exact same error message above. I have also tried increasing timeout range to 100 or even to 1000, as suggested in other posts, because, well, Windows... but as expected it only took longer to fail.

Can anyone help me decipher and fix these, please? Thanks a lot!

(Switching to Linux not an option at this time...)


回答1:


I know this is an old post, but trying to help however is having the same problem.

Fixed this issue by changing the priority from IPv6 to IPv4.

You can try temporarily disable the IPv6 protocol, then try PIP again. If it works, i recommend reactivating IPv6 then searching about IPv4 priority over IPv6, the way to do it changes depending of OS.



来源:https://stackoverflow.com/questions/52461613/pip-readtimeouterror-in-windows-10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!