试图安装Spacy英语语言模型,得到urlopen错误

时间:2016-08-24 13:49:49

标签: python python-3.x spacy

我试图在带有python 3的anaconda环境中使用Windows 8安装spaCy。按照spaCy网站上的说明,我运行以下命令。

$ pip install spacy
$ python -m spacy.en.download

第一个命令看似很好。但是,第二个命令会导致错误: urllib.error.URLError:

完整的追溯:

Traceback (most recent call last):

  File "C:\Users\Tina\Miniconda3\envs\gaia\lib\urllib\request.py", line 1254, in
 do_open
    h.request(req.get_method(), req.selector, req.data, headers)
  File "C:\Users\Tina\Miniconda3\envs\gaia\lib\http\client.py", line 1106, in re
quest
    self._send_request(method, url, body, headers)
  File "C:\Users\Tina\Miniconda3\envs\gaia\lib\http\client.py", line 1151, in _s
end_request
    self.endheaders(body)
  File "C:\Users\Tina\Miniconda3\envs\gaia\lib\http\client.py", line 1102, in en
dheaders
    self._send_output(message_body)
  File "C:\Users\Tina\Miniconda3\envs\gaia\lib\http\client.py", line 934, in _se
nd_output
    self.send(msg)
  File "C:\Users\Tina\Miniconda3\envs\gaia\lib\http\client.py", line 877, in sen
d
    self.connect()
  File "C:\Users\Tina\Miniconda3\envs\gaia\lib\http\client.py", line 1252, in co
nnect
    super().connect()
  File "C:\Users\Tina\Miniconda3\envs\gaia\lib\http\client.py", line 849, in con
nect
    (self.host,self.port), self.timeout, self.source_address)
  File "C:\Users\Tina\Miniconda3\envs\gaia\lib\socket.py", line 693, in create_c
onnection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "C:\Users\Tina\Miniconda3\envs\gaia\lib\socket.py", line 732, in getaddri
nfo
    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 "C:\Users\Tina\Miniconda3\envs\gaia\lib\runpy.py", line 184, in _run_modu
le_as_main
    "__main__", mod_spec)
  File "C:\Users\Tina\Miniconda3\envs\gaia\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\Tina\Miniconda3\envs\gaia\lib\site-packages\spacy\en\download.p
y", line 13, in <module>
    plac.call(main)
  File "C:\Users\Tina\Miniconda3\envs\gaia\lib\site-packages\plac_core.py", line
 328, in call
    cmd, result = parser.consume(arglist)
  File "C:\Users\Tina\Miniconda3\envs\gaia\lib\site-packages\plac_core.py", line
 207, in consume
    return cmd, self.func(*(args + varargs + extraopts), **kwargs)
  File "C:\Users\Tina\Miniconda3\envs\gaia\lib\site-packages\spacy\en\download.p
y", line 9, in main
    download('en', force)
  File "C:\Users\Tina\Miniconda3\envs\gaia\lib\site-packages\spacy\download.py",
 line 24, in download
    package = sputnik.install(about.__title__, about.__version__, about.__models
__[lang])
  File "C:\Users\Tina\Miniconda3\envs\gaia\lib\site-packages\sputnik-0.9.3-py3.5
.egg\sputnik\__init__.py", line 37, in install
  File "C:\Users\Tina\Miniconda3\envs\gaia\lib\site-packages\sputnik-0.9.3-py3.5
.egg\sputnik\index.py", line 84, in update
  File "C:\Users\Tina\Miniconda3\envs\gaia\lib\site-packages\sputnik-0.9.3-py3.5
.egg\sputnik\session.py", line 43, in open
  File "C:\Users\Tina\Miniconda3\envs\gaia\lib\urllib\request.py", line 466, in
open
    response = self._open(req, data)
  File "C:\Users\Tina\Miniconda3\envs\gaia\lib\urllib\request.py", line 484, in
_open
    '_open', req)
  File "C:\Users\Tina\Miniconda3\envs\gaia\lib\urllib\request.py", line 444, in
_call_chain
    result = func(*args)
  File "C:\Users\Tina\Miniconda3\envs\gaia\lib\urllib\request.py", line 1297, in
 https_open
    context=self._context, check_hostname=self._check_hostname)
  File "C:\Users\Tina\Miniconda3\envs\gaia\lib\urllib\request.py", line 1256, in
 do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 11004] getaddrinfo failed>

其他类似的问题似乎表明代理可能是问题,但我没有使用代理。

1 个答案:

答案 0 :(得分:0)

&#39; python -m ...&#39;运行/升级现有模型时应使用该命令。如果您是第一次下载模型,请使用本应作为spaCy依赖项安装的sputnik软件包管理器:

sputnik --name spacy --repository-url http://index.spacy.io install en==1.1.0