gpt4 book ai didi

python - 安装 python 模块时出现错误 "socket.timeout: The read operation timed out"

转载 作者:行者123 更新时间:2023-12-03 13:31:56 30 4
gpt4 key购买 nike

我正在尝试为 spaCy(自然语言处理库)安装大型英语模块“en_core_web_lg”

由于某些原因,成功安装了中小型模块(起初几乎没有错误),
但大模块总是崩溃安装。

我使用了两种不同的方法:

1)

$ python -m spacy download en_core_web_lg

2)
$ pip install https://github.com/explosion/spacy-models/releases/download/en_core_web_lg-2.0.0/en_core_web_lg-2.0.0.tar.gz
但在这两种情况下,我总是得到这两个异常(exception):
(venv) omar@omar-device:~/virtualenvironment/my_new_app/bin/venv/bin$ pip3 install https://github.com/explosion/spacy-models/releases/download/en_core_web_lg-2.0.0/en_core_web_lg-2.0.0.tar.gz
Collecting https://github.com/explosion/spacy-models/releases/download/en_core_web_lg-2.0.0/en_core_web_lg-2.0.0.tar.gz
Downloading https://github.com/explosion/spacy-models/releases/download/en_core_web_lg-2.0.0/en_core_web_lg-2.0.0.tar.gz (852.3MB)
38% |████████████▎ | 325.7MB 114kB/s eta 1:16:26Exception:
Traceback (most recent call last):
File "/home/omar/virtualenvironment/my_new_app/bin/venv/lib/python3.5/site-packages/pip/_vendor/urllib3/response.py", line 331, in _error_catcher
yield
File "/home/omar/virtualenvironment/my_new_app/bin/venv/lib/python3.5/site-packages/pip/_vendor/urllib3/response.py", line 413, in read
data = self._fp.read(amt)
File "/home/omar/virtualenvironment/my_new_app/bin/venv/lib/python3.5/site-packages/pip/_vendor/cachecontrol/filewrapper.py", line 62, in read
data = self.__fp.read(amt)
File "/usr/lib/python3.5/http/client.py", line 448, in read
n = self.readinto(b)
File "/usr/lib/python3.5/http/client.py", line 488, in readinto
n = self.fp.readinto(b)
File "/usr/lib/python3.5/socket.py", line 575, in readinto
return self._sock.recv_into(b)
File "/usr/lib/python3.5/ssl.py", line 929, in recv_into
return self.read(nbytes, buffer)
File "/usr/lib/python3.5/ssl.py", line 791, in read
return self._sslobj.read(len, buffer)
File "/usr/lib/python3.5/ssl.py", line 575, in read
v = 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 "/home/omar/virtualenvironment/my_new_app/bin/venv/lib/python3.5/site-packages/pip/_internal/basecommand.py", line 141, in main
status = self.run(options, args)
File "/home/omar/virtualenvironment/my_new_app/bin/venv/lib/python3.5/site-packages/pip/_internal/commands/install.py", line 299, in run
resolver.resolve(requirement_set)
File "/home/omar/virtualenvironment/my_new_app/bin/venv/lib/python3.5/site-packages/pip/_internal/resolve.py", line 102, in resolve
self._resolve_one(requirement_set, req)
File "/home/omar/virtualenvironment/my_new_app/bin/venv/lib/python3.5/site-packages/pip/_internal/resolve.py", line 256, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "/home/omar/virtualenvironment/my_new_app/bin/venv/lib/python3.5/site-packages/pip/_internal/resolve.py", line 209, in _get_abstract_dist_for
self.require_hashes
File "/home/omar/virtualenvironment/my_new_app/bin/venv/lib/python3.5/site-packages/pip/_internal/operations/prepare.py", line 283, in prepare_linked_requirement
progress_bar=self.progress_bar
File "/home/omar/virtualenvironment/my_new_app/bin/venv/lib/python3.5/site-packages/pip/_internal/download.py", line 836, in unpack_url
progress_bar=progress_bar
File "/home/omar/virtualenvironment/my_new_app/bin/venv/lib/python3.5/site-packages/pip/_internal/download.py", line 673, in unpack_http_url
progress_bar)
File "/home/omar/virtualenvironment/my_new_app/bin/venv/lib/python3.5/site-packages/pip/_internal/download.py", line 897, in _download_http_url
_download_url(resp, link, content_file, hashes, progress_bar)
File "/home/omar/virtualenvironment/my_new_app/bin/venv/lib/python3.5/site-packages/pip/_internal/download.py", line 619, in _download_url
consume(downloaded_chunks)
File "/home/omar/virtualenvironment/my_new_app/bin/venv/lib/python3.5/site-packages/pip/_internal/utils/misc.py", line 844, in consume
deque(iterator, maxlen=0)
File "/home/omar/virtualenvironment/my_new_app/bin/venv/lib/python3.5/site-packages/pip/_internal/download.py", line 585, in written_chunks
for chunk in chunks:
File "/home/omar/virtualenvironment/my_new_app/bin/venv/lib/python3.5/site-packages/pip/_internal/utils/ui.py", line 159, in iter
for x in it:
File "/home/omar/virtualenvironment/my_new_app/bin/venv/lib/python3.5/site-packages/pip/_internal/download.py", line 574, in resp_read
decode_content=False):
File "/home/omar/virtualenvironment/my_new_app/bin/venv/lib/python3.5/site-packages/pip/_vendor/urllib3/response.py", line 465, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "/home/omar/virtualenvironment/my_new_app/bin/venv/lib/python3.5/site-packages/pip/_vendor/urllib3/response.py", line 430, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__
self.gen.throw(type, value, traceback)
File "/home/omar/virtualenvironment/my_new_app/bin/venv/lib/python3.5/site-packages/pip/_vendor/urllib3/response.py", line 336, in _error_catcher
raise ReadTimeoutError(self._pool, None, 'Read timed out.')
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='github-production-release-asset-2e65be.s3.amazonaws.com', port=443): Read timed out.

我一开始尝试重新安装 Python3,但我的桌面和终端崩溃了,不得不使用控制台修复它:D(使用这个答案 https://askubuntu.com/questions/384033/removed-python-3-and-now-ubuntu-software-center-terminal-and-other-applications)。

最佳答案

尝试增加 pip 超时:pip install --default-timeout=900 [pkg_name]

关于python - 安装 python 模块时出现错误 "socket.timeout: The read operation timed out",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51542570/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com