三行代码  ›  专栏  ›  技术社区  ›  Kiera.K

Spacy语言模块未下载

  •  0
  • Kiera.K  · 技术社区  · 3 年前

    我在为ubuntu 16.04工作。我用康达下载SPACY,我在Joopter笔记本上工作。 我试过了

    python -m spacy download en
    

    给出以下错误:

    /home/nikita/anaconda3/bin/python:没有名为spacy的模块。 主要的 ;“spacy”是一个包,不能直接执行

    所以我试着

    python -m spacy.en.download
    

    从而产生这些错误:

     Traceback (most recent call last):
    File "/home/nikita/anaconda3/lib/python3.6/urllib/request.py", line 1318, in do_open encode_chunked=req.has_header('Transfer-encoding'))
    
    File "/home/nikita/anaconda3/lib/python3.6/http/client.py", line 1239, in request self._send_request(method, url, body, headers, encode_chunked)
    
     File "/home/nikita/anaconda3/lib/python3.6/http/client.py", line 1285, in _send_request
        self.endheaders(body, encode_chunked=encode_chunked)
    File "/home/nikita/anaconda3/lib/python3.6/http/client.py", line 1234, in endheaders self._send_output(message_body, encode_chunked=encode_chunked)
    File "/home/nikita/anaconda3/lib/python3.6/http/client.py", line 1026, in _send_output self.send(msg)
    File "/home/nikita/anaconda3/lib/python3.6/http/client.py", line 964, in send self.connect()
    File "/home/nikita/anaconda3/lib/python3.6/http/client.py", line 1392, in connect super().connect()
    File "/home/nikita/anaconda3/lib/python3.6/http/client.py", line 936, in connect(self.host,self.port), self.timeout, self.source_address)
    File "/home/nikita/anaconda3/lib/python3.6/socket.py", line 724, in create_connection raise err
    File "/home/nikita/anaconda3/lib/python3.6/socket.py", line 713, in create_connection sock.connect(sa)
    ConnectionRefusedError: [Errno 111] Connection refused
    
     During handling of the above exception, another exception occurred:
    
     Traceback (most recent call last):
    File "/home/nikita/anaconda3/lib/python3.6/runpy.py", line 193, in _run_module_as_main  "__main__", mod_spec)
    File "/home/nikita/anaconda3/lib/python3.6/runpy.py", line 85, in _run_code
        exec(code, run_globals)
    File "/home/nikita/anaconda3/lib/python3.6/site-packages/spacy/en/download.py", line 13, in <module  plac.call(main)
    File "/home/nikita/anaconda3/lib/python3.6/site-packages/plac_core.py", line 328, in call  cmd, result = parser.consume(arglist)
    File "/home/nikita/anaconda3/lib/python3.6/site-packages/plac_core.py", line 207, in consume  return cmd, self.func(*(args + varargs + extraopts), **kwargs)
    File "/home/nikita/anaconda3/lib/python3.6/site-packages/spacy/en/download.py", line 9, in main   download('en', force)
    File "/home/nikita/anaconda3/lib/python3.6/site-packages/spacy/download.py", line 24, in download   package = sputnik.install(about.__title__, about.__version__, about.__models__[lang])
    File "/home/nikita/anaconda3/lib/python3.6/site-packages/sputnik/__init__.py", line 37, in install  index.update()
    File "/home/nikita/anaconda3/lib/python3.6/site-packages/sputnik/index.py", line 84, in update index = json.load(session.open(request, 'utf8'))
    File "/home/nikita/anaconda3/lib/python3.6/site-packages/sputnik/session.py", line 43, in open    r = self.opener.open(request)
    File "/home/nikita/anaconda3/lib/python3.6/urllib/request.py", line 526, in open    response = self._open(req, data)
    File "/home/nikita/anaconda3/lib/python3.6/urllib/request.py", line 544, in _open    '_open', req)
    File "/home/nikita/anaconda3/lib/python3.6/urllib/request.py", line 504, in _call_chain    result = func(*args)
    File "/home/nikita/anaconda3/lib/python3.6/urllib/request.py", line 1361, in https_open    context=self._context, check_hostname=self._check_hostname)
    File "/home/nikita/anaconda3/lib/python3.6/urllib/request.py", line 1320, in do_open    raise URLError(err)
    urllib.error.URLError: <urlopen error [Errno 111] Connection refused
    Exception ignored in: <bound method Session.__del__ of <sputnik.session.Session object at 0x7f30d010d828
    Traceback (most recent call last):
    File "/home/nikita/anaconda3/lib/python3.6/site-packages/sputnik/session.py", line 58, in __del__
    File "/home/nikita/anaconda3/lib/python3.6/http/cookiejar.py", line 2070, in save
    NameError: name 'open' is not defined 
    

    然后我试着

    python3 -m spacy.en.download --force all
    

    与第二个错误相同。 请帮忙!

    1 回复  |  直到 3 年前
        1
  •  1
  •   Ines Montani    3 年前

    出于某种原因,康达似乎已经安装了一个旧版本的SPACY。要确保安装的是最新版本(或任何其他特定版本),可以使用以下命令:

    conda install -c conda-forge spacy=2.0.11
    

    (免责声明:我是Spacy的维护者之一。我们仍在调查一些用户为什么会发生这种情况,以及它是否与依赖关系的解决有关,一个古老的蟒蛇分布与Spess一起传播。 0.101.0 或者完全不同的东西。问题跟踪器上的相关线程是 here (第三章)