[Error]pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool

Error Detail

When I install PySide2 with pip command, the error below occurred. There are 2 exceptions “socket.timeout: The read operation timed out” and “pip._vendor.urllib3.exceptions.ReadTimeoutError“.

<!–more–>

>pip install pyside2
Collecting pyside2
  Downloading PySide2-5.15.2-5.15.2-cp35.cp36.cp37.cp38.cp39-none-win_amd64.whl (136.3 MB)
     |██████████████████              | 75.3 MB 25 kB/s eta 0:40:29ERROR: Exception:
Traceback (most recent call last):
  File "c:\users\<user_name>\appdata\local\programs\python\python38\lib\site-packages\pip\_vendor\urllib3\response.py", line 437, in _error_catcher
    yield
.
.
. Omitted
.
.
  File "c:\users\<user_name>\appdata\local\programs\python\python38\lib\ssl.py", line 1099, in read
    return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\<user_name>\appdata\local\programs\python\python38\lib\site-packages\pip\_internal\cli\base_command.py", line 228, in _main
    status = self.run(options, args)
.
.
. Omitted
.
.
  File "c:\users\<user_name>\appdata\local\programs\python\python38\lib\site-packages\pip\_vendor\urllib3\response.py", line 442, in _error_catcher
    raise ReadTimeoutError(self._pool, None, "Read timed out.")
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.

Environment

Windows 10
Pyhon 3.8.7
pip 20.2.3

Cause

When response couldn’t gotten in time, both of exceptions are occurred. The time is defined by environment variable “PIP_DEFAULT_TIMEOUT”.

The cause is just a poor connection in my case.

Solution

Change the value of PIP_DEFAULT_TIMEOUT (the value is an integer in seconds).
Reference : “Environment Variables” from pip documentation

Method 1. Pass the option to pip directly

pip --default-timeout=1200 install pyside2

Method 2. Set the default value

set PIP_DEFAULT_TIMEOUT=1200