导入spaCy错误

时间:2017-10-23 10:31:45

标签: python python-import spacy

当我尝试导入spaCy时(第一次),我收到了以下错误:

>>>import spacy
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import spacy
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/spacy/__init__.py", line 10, in <module>
    from . import en, de, zh, es, it, hu, fr, pt, nl, sv, fi, bn, he, nb, ja
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/spacy/en/__init__.py", line 4, in <module>
    from ..language import Language
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/spacy/language.py", line 14, in <module>
    from .pipeline import DependencyParser, EntityRecognizer
  File "spacy/pipeline.pyx", line 1, in init spacy.pipeline (spacy/pipeline.cpp:16536)
    # coding: utf8
  File ".env/lib/python2.7/site-packages/thinc/extra/search.pxd", line 72, in init spacy.syntax.beam_parser (spacy/syntax/beam_parser.cpp:20037)
ValueError: thinc.extra.search.MaxViolation has the wrong size, try recompiling

建议我重新编译。我该怎么做才能解决这个错误?

2 个答案:

答案 0 :(得分:1)

可能与thincspacy存在版本冲突。它已在thinc v6.9.0中修复!

我建议您使用sudo pip uninstall thincsudo pip3 uninstall thinc卸载并重新安装此处提供的thinc版本6.9.0:https://pypi.python.org/pypi/thinc

答案 1 :(得分:0)

问题可能是使用thinc包,对于spacy-nightly它需要thinc&lt; 6.9.0,&gt; = 6.8.1但版本6.8.2导致一些问题 - &gt;我认为这对于spacy来说将是同样的问题;如何解决它的方法是在安装spacy

之前运行命令
pip install thinc==6.8.1