問題
Poetry で Torch をインストールするときに、コネクションがタイムアウトしてしまった。
エラー文抜粋:
• Installing torch (2.0.1): Failed
timeout
The read operation timed out
ReadTimeoutError
HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
エラー文全体
# 前略...
• Installing torch (2.0.1): Failed
timeout
The read operation timed out
at /usr/lib/python3.8/ssl.py:1099 in read
1095│ if self._sslobj is None:
1096│ raise ValueError("Read on closed or unwrapped SSL socket.")
1097│ try:
1098│ if buffer is not None:
→ 1099│ return self._sslobj.read(len, buffer)
1100│ else:
1101│ return self._sslobj.read(len)
1102│ except SSLError as x:
1103│ if x.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs:
The following error occurred when trying to handle this error:
ReadTimeoutError
HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
at ~/.local/pipx/venvs/poetry/lib/python3.8/site-packages/urllib3/response.py:715 in _error_catcher
711│
712│ except SocketTimeout as e:
713│ # FIXME: Ideally we'd like to include the url in the ReadTimeoutError but
714│ # there is yet no clean way to get at it from this context.
→ 715│ raise ReadTimeoutError(self._pool, None, "Read timed out.") from e # type: ignore[arg-type]
716│
717│ except BaseSSLError as e:
718│ # FIXME: Is there a better way to differentiate between SSLErrors?
719│ if "read operation timed out" not in str(e):
The following error occurred when trying to handle this error:
ConnectionError
HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
at ~/.local/pipx/venvs/poetry/lib/python3.8/site-packages/requests/models.py:822 in generate
818│ raise ChunkedEncodingError(e)
819│ except DecodeError as e:
820│ raise ContentDecodingError(e)
821│ except ReadTimeoutError as e:
→ 822│ raise ConnectionError(e)
823│ except SSLError as e:
824│ raise RequestsSSLError(e)
825│ else:
826│ # Standard file-like object.
Cannot install torch.
解決
インストールしようとしていた Torch が大きすぎてタイムアウトしていた様子。
環境変数でタイムアウトを伸ばせるようになっているらしい。
POETRY_REQUESTS_TIMEOUT=600 poetry install
うまくいった。