我正在尝试为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
但是在两种情况下,我总是会遇到以下两个异常:
(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,但是崩溃了我的台式机和终端机,不得不使用console:D(使用此答案https://askubuntu.com/questions/384033/removed-python-3-and-now-ubuntu-software-center-terminal-and-other-applications)进行修复。
答案 0 :(得分:3)
尝试增加点子超时:pip install --default-timeout=900 [pkg_name]
答案 1 :(得分:0)
我在系统环境和虚拟环境中都尝试了很多次,一次下载达到了100%(〜850MB),然后又给了我这个错误!因此,问题显然不在下载步骤中,而是在其后的直接安装中。
所以我考虑过分两个步骤: 首先使用以下命令下载该模块:
$ wget "https://github.com/explosion/spacy-models/releases/download/en_core_web_lg-2.0.0/en_core_web_lg-2.0.0.tar.gz"
然后使用
安装$ pip install en_core_web_lg-2.0.0.tar.gz
工作顺利。
我确实解决了最初的问题,但是我仍然不知道是什么原因导致了它的发生(如果您知道,请写一个答案)。