当我安装完 spacy 库后,要安装 英文包 en_core_web_sm, 安装官网给的命令:
python -m spacy download [en_core_web_sm]
然后报错了,完整报错如下:
Traceback (most recent call last):
File "E:\Anaconda\lib\site-packages\urllib3\connection.py", line 171, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw)
File "E:\Anaconda\lib\site-packages\urllib3\util\connection.py", line 56, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File "E:\Anaconda\lib\socket.py", line 748, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11004] getaddrinfo failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\Anaconda\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
chunked=chunked)
File "E:\Anaconda\lib\site-packages\urllib3\connectionpool.py", line 343, in _make_request
self._validate_conn(conn)
File "E:\Anaconda\lib\site-packages\urllib3\connectionpool.py", line 849, in _validate_conn
conn.connect()
File "E:\Anaconda\lib\site-packages\urllib3\connection.py", line 314, in connect
conn = self._new_conn()
File "E:\Anaconda\lib\site-packages\urllib3\connection.py", line 180, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 11004] getaddrinfo failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\Anaconda\lib\site-packages\requests\adapters.py", line 449, in send
timeout=timeout
File "E:\Anaconda\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "E:\Anaconda\lib\site-packages\urllib3\util\retry.py", line 398, 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(': Failed to establish a new connection: [Errno 11004] getaddrinfo failed'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\Anaconda\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "E:\Anaconda\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "E:\Anaconda\lib\site-packages\spacy\__main__.py", line 33, in
plac.call(commands[command], sys.argv[1:])
File "E:\Anaconda\lib\site-packages\plac_core.py", line 367, in call
cmd, result = parser.consume(arglist)
File "E:\Anaconda\lib\site-packages\plac_core.py", line 232, in consume
return cmd, self.func(*(args + varargs + extraopts), **kwargs)
File "E:\Anaconda\lib\site-packages\spacy\cli\download.py", line 44, in download
shortcuts = get_json(about.__shortcuts__, "available shortcuts")
File "E:\Anaconda\lib\site-packages\spacy\cli\download.py", line 95, in get_json
r = requests.get(url)
File "E:\Anaconda\lib\site-packages\requests\api.py", line 76, in get
return request('get', url, params=params, **kwargs)
File "E:\Anaconda\lib\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "E:\Anaconda\lib\site-packages\requests\sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "E:\Anaconda\lib\site-packages\requests\sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "E:\Anaconda\lib\site-packages\requests\adapters.py", line 516, 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(': Failed to establish a new connection: [Errno 11004] getaddrinfo failed'))
不通过spacy,直接命令行去github下载:
pip install https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.2.0/en_core_web_sm-2.2.0.tar.gz
如果pip网速不好的话,直接去github手动下载,然后手动安装:
下载地址:
https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.2.0/en_core_web_sm-2.2.0.tar.gz
然后在该文件的目录下直接用pip安装:
pip install en_core_web_sm-2.2.0/en_core_web_sm-2.2.0.tar.gz