spacy模块安装在conda

时间:2017-09-23 18:40:35

标签: python conda spacy

在Windows 7机器上使用conda安装spacy后,我运行了以下代码:

import spacy
nlp = spacy.load('en')

我收到的错误如下:

Warning: no model found for 'en'

Only loading the 'en' tokenizer.

在一些搜索之后,我在命令行(cmd)上运行了以下代码:

python -m spacy download en

我收到的错误是:

    Traceback (most recent call last):
     File "C:\Users\vranjan2\AppData\Local\Continuum\Anaconda3\lib\runpy.py", line
    193, in _run_module_as_main

    "__main__", mod_spec)
  File "C:\Users\vranjan2\AppData\Local\Continuum\Anaconda3\lib\runpy.py", line
85, in _run_code
    exec(code, run_globals)
  File "C:\Users\vranjan2\AppData\Local\Continuum\Anaconda3\lib\site-packages\sp
acy\__main__.py", line 133, in <module>
    plac.Interpreter.call(CLI)
  File "C:\Users\vranjan2\AppData\Local\Continuum\Anaconda3\lib\site-packages\pl
ac_ext.py", line 1142, in call
    print(out)
  File "C:\Users\vranjan2\AppData\Local\Continuum\Anaconda3\lib\site-packages\pl
ac_ext.py", line 914, in __exit__
    self.close(exctype, exc, tb)
  File "C:\Users\vranjan2\AppData\Local\Continuum\Anaconda3\lib\site-packages\pl
ac_ext.py", line 952, in close
    self._interpreter.throw(exctype, exc, tb)
  File "C:\Users\vranjan2\AppData\Local\Continuum\Anaconda3\lib\site-packages\pl
ac_ext.py", line 964, in _make_interpreter
    arglist = yield task
  File "C:\Users\vranjan2\AppData\Local\Continuum\Anaconda3\lib\site-packages\pl
ac_ext.py", line 1139, in call
    raise_(task.etype, task.exc, task.tb)
  File "C:\Users\vranjan2\AppData\Local\Continuum\Anaconda3\lib\site-packages\pl
ac_ext.py", line 53, in raise_
    raise exc.with_traceback(tb)
  File "C:\Users\vranjan2\AppData\Local\Continuum\Anaconda3\lib\site-packages\pl
ac_ext.py", line 380, in _wrap
    for value in genobj:
  File "C:\Users\vranjan2\AppData\Local\Continuum\Anaconda3\lib\site-packages\pl
ac_ext.py", line 95, in gen_exc
    raise_(etype, exc, tb)
  File "C:\Users\vranjan2\AppData\Local\Continuum\Anaconda3\lib\site-packages\pl
ac_ext.py", line 53, in raise_
    raise exc.with_traceback(tb)
  File "C:\Users\vranjan2\AppData\Local\Continuum\Anaconda3\lib\site-packages\pl
ac_ext.py", line 966, in _make_interpreter
    cmd, result = self.parser.consume(arglist)
  File "C:\Users\vranjan2\AppData\Local\Continuum\Anaconda3\lib\site-packages\pl
ac_core.py", line 207, in consume
    return cmd, self.func(*(args + varargs + extraopts), **kwargs)
  File "C:\Users\vranjan2\AppData\Local\Continuum\Anaconda3\lib\site-packages\sp
acy\__main__.py", line 33, in download
    cli_download(model, direct)
  File "C:\Users\vranjan2\AppData\Local\Continuum\Anaconda3\lib\site-packages\sp
acy\cli\download.py", line 20, in download
    model_name = check_shortcut(model)
  File "C:\Users\vranjan2\AppData\Local\Continuum\Anaconda3\lib\site-packages\sp
acy\cli\download.py", line 39, in check_shortcut
    shortcuts = get_json(about.__shortcuts__, "available shortcuts")
  File "C:\Users\vranjan2\AppData\Local\Continuum\Anaconda3\lib\site-packages\sp
acy\cli\download.py", line 28, in get_json
    r = requests.get(url)
  File "C:\Users\vranjan2\AppData\Local\Continuum\Anaconda3\lib\site-packages\re
quests\api.py", line 72, in get
    return request('get', url, params=params, **kwargs)
  File "C:\Users\vranjan2\AppData\Local\Continuum\Anaconda3\lib\site-packages\re
quests\api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Users\vranjan2\AppData\Local\Continuum\Anaconda3\lib\site-packages\re
quests\sessions.py", line 518, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\vranjan2\AppData\Local\Continuum\Anaconda3\lib\site-packages\re
quests\sessions.py", line 639, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\vranjan2\AppData\Local\Continuum\Anaconda3\lib\site-packages\re
quests\adapters.py", line 512, in send
    raise SSLError(e, request=request)
    requests.exceptions.SSLError: ("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",)

该错误似乎与SSL的防火墙问题有关。我尝试通过添加--trusted-host来修改代码。

我尝试直接从Github网站下载模型文件,但仍然出现以下错误:screenshot of ssl error

1 个答案:

答案 0 :(得分:1)

如果下载命令失败,另一种方法是:

所有下载和使用模型的方法都在https://spacy.io/docs/usage/models

的spacy网站上