当前位置:   article > 正文

en_core_web_sm安装报错:requests.exceptions.ConnectionError: HTTPSConnectionPool(host=‘raw.githubusercont

en_core_web_sm安装报错:requests.exceptions.ConnectionError: HTTPSConnectionPool(host=‘raw.githubusercont

en_core_web_sm安装报错


问题描述

当我安装完 spacy 库后,要安装 英文包 en_core_web_sm, 安装官网给的命令:

python -m spacy download [en_core_web_sm]
  • 1

然后报错了,完整报错如下:

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: <urllib3.connection.VerifiedHTTPSConnection object at 0x00000239D462BA90>: 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('<urllib3.connection.VerifiedHTTPSConnection object at 0x00000239D462BA90>: 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 <module>
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('<urllib3.connection.VerifiedHTTPSConnection object at 0x00000239D462BA90>: Failed to establish a new connection: [Errno 11004] getaddrinfo failed'))
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63

解决办法

方法一

不通过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
  • 1

方法二

如果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
  • 1

然后在该文件的目录下直接用pip安装:

pip install en_core_web_sm-2.2.0/en_core_web_sm-2.2.0.tar.gz
  • 1
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/818726
推荐阅读
相关标签
  

闽ICP备14008679号