python -m spacy download en_core_web_sm
报错
Traceback (most recent call last):
File “/opt/conda/envs/spanrel/lib/python3.6/site-packages/urllib3/connection.py”, line 175, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw
File “/opt/conda/envs/spanrel/lib/python3.6/site-packages/urllib3/util/connection.py”, line 95, in create_connection
raise err
File “/opt/conda/envs/spanrel/lib/python3.6/site-packages/urllib3/util/connection.py”, line 85, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/opt/conda/envs/spanrel/lib/python3.6/site-packages/urllib3/connectionpool.py”, line 721, in urlopen
chunked=chunked,
File “/opt/conda/envs/spanrel/lib/python3.6/site-packages/urllib3/connectionpool.py”, line 403, in _make_request
self._validate_conn(conn)
File “/opt/conda/envs/spanrel/lib/python3.6/site-packages/urllib3/connectionpool.py”, line 1053, in _validate_conn
conn.connect()
File “/opt/conda/envs/spanrel/lib/python3.6/site-packages/urllib3/connection.py”, line 363, in connect
self.sock = conn = self._new_conn()
File “/opt/conda/envs/spanrel/lib/python3.6/site-packages/urllib3/connection.py”, line 187, in _new_conn
self, “Failed to establish a new connection: %s” % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7fdac8fc94e0>: Failed to establish a new connection: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/opt/conda/envs/spanrel/lib/python3.6/site-packages/requests/adapters.py”, line 450, in send
timeout=timeout
File “/opt/conda/envs/spanrel/lib/python3.6/site-packages/urllib3/connectionpool.py”, line 799, in urlopen
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
File “/opt/conda/envs/spanrel/lib/python3.6/site-packages/urllib3/util/retry.py”, line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host=‘raw.githubusercontent.com’, port=443): Max retries exceeded with url: /explosion/spacy-models/master/shortcuts-v2.json (Caused by NewConnectionError(‘<urllib3.connection.HTTPSConnection object at 0x7fdac8fc94e0>: Failed to establish a new connection: [Errno 111] Connection refused’,))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/opt/conda/envs/spanrel/lib/python3.6/runpy.py”, line 193, in _run_module_as_main
“main”, mod_spec)
File “/opt/conda/envs/spanrel/lib/python3.6/runpy.py”, line 85, in _run_code
exec(code, run_globals)
File “/opt/conda/envs/spanrel/lib/python3.6/site-packages/spacy/main.py”, line 35, in
plac.call(commands[command], sys.argv[1:])
File “/opt/conda/envs/spanrel/lib/python3.6/site-packages/plac_core.py”, line 328, in call
cmd, result = parser.consume(arglist)
File “/opt/conda/envs/spanrel/lib/python3.6/site-packages/plac_core.py”, line 207, in consume
return cmd, self.func(*(args + varargs + extraopts), **kwargs)
File “/opt/conda/envs/spanrel/lib/python3.6/site-packages/spacy/cli/download.py”, line 38, in download
shortcuts = get_json(about.shortcuts, “available shortcuts”)
File “/opt/conda/envs/spanrel/lib/python3.6/site-packages/spacy/cli/download.py”, line 84, in get_json
r = requests.get(url)
File “/opt/conda/envs/spanrel/lib/python3.6/site-packages/requests/api.py”, line 75, in get
return request(‘get’, url, params=params, **kwargs)
File “/opt/conda/envs/spanrel/lib/python3.6/site-packages/requests/api.py”, line 61, in request
return session.request(method=method, url=url, **kwargs)
File “/opt/conda/envs/spanrel/lib/python3.6/site-packages/requests/sessions.py”, line 529, in request
resp = self.send(prep, **send_kwargs)
File “/opt/conda/envs/spanrel/lib/python3.6/site-packages/requests/sessions.py”, line 645, in send
r = adapter.send(request, **kwargs)
File “/opt/conda/envs/spanrel/lib/python3.6/site-packages/requests/adapters.py”, line 519, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host=‘raw.githubusercontent.com’, port=443): Max retries exceeded with url: /explosion/spacy-models/master/shortcuts-v2.json (Caused by NewConnectionError(‘<urllib3.connection.HTTPSConnection object at 0x7fdac8fc94e0>: Failed to establish a new connection: [Errno 111] Connection refused’,))
解决方案:
手动下载en_core_web_sm
然年pip install
参考:https://blog.csdn.net/chouchoubuchou/article/details/117957057