无法下载 spacy 模型

unable to download spacy model

正在通过以下命令下载 spacy "en" 模型

python -m spacy download en

抛出 URL 错误。

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/siddharthdas/venvs/chai/lib/python3.6/site-packages/spacy/__main__.py", line 31, in <module>
    plac.call(commands[command], sys.argv[1:])
  File "/Users/siddharthdas/venvs/chai/lib/python3.6/site-packages/plac_core.py", line 328, in call
    cmd, result = parser.consume(arglist)
  File "/Users/siddharthdas/venvs/chai/lib/python3.6/site-packages/plac_core.py", line 207, in consume
    return cmd, self.func(*(args + varargs + extraopts), **kwargs)
  File "/Users/siddharthdas/venvs/chai/lib/python3.6/site-packages/spacy/cli/download.py", line 30, in download
    shortcuts = get_json(about.__shortcuts__, "available shortcuts")
  File "/Users/siddharthdas/venvs/chai/lib/python3.6/site-packages/spacy/cli/download.py", line 55, in get_json
    data = url_read(url)
  File "/Users/siddharthdas/venvs/chai/lib/python3.6/site-packages/spacy/compat.py", line 82, in url_read
    file_ = url_open(url)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 526, in open
    response = self._open(req, data)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 544, in _open
    '_open', req)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1361, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1320, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)>

然后我尝试安装Install Certificates.command,但没有解决问题。

规格

OS:Mac 高山脉

ENV:venv(python虚拟环境)

问题可能与 this issue and PR 有关,而且与 requests 不同的是,urllib 不会在额外的地方检查证书。

经过一些来回,即将发布的 spaCy 版本将恢复此更改并返回使用 requests - 删除依赖项不值得麻烦。同时,您始终可以通过将 pip install 指向直接 URL 来手动下载和安装模型。 See this section 在文档中了解详细信息。