加载spacy模型时出错AttributeError:module'msgpack._unpacker'没有属性'unpack'

时间:2018-02-22 12:02:58

标签: python-3.x nlp python-3.6 spacy msgpack

我在为spacy 2.0.8加载模型时遇到问题,但对于以前的版本2.0.7也是如此。你有什么想法吗?

提前致谢

    nlp = spacy.load('en_core_web_lg', disable=['ner'])
  File "/usr/lib64/python3.6/site-packages/spacy/__init__.py", line 19, in load
    return util.load_model(name, **overrides)
  File "/usr/lib64/python3.6/site-packages/spacy/util.py", line 113, in load_model
    return load_model_from_link(name, **overrides)
  File "/usr/lib64/python3.6/site-packages/spacy/util.py", line 132, in load_model_from_link
    return cls.load(**overrides)
  File "/usr/lib64/python3.6/site-packages/spacy/data/en_core_web_lg/__init__.py", line 12, in load
    return load_model_from_init_py(__file__, **overrides)
  File "/usr/lib64/python3.6/site-packages/spacy/util.py", line 177, in load_model_from_init_py
    return load_model_from_path(data_path, meta, **overrides)
  File "/usr/lib64/python3.6/site-packages/spacy/util.py", line 159, in load_model_from_path
    return nlp.from_disk(model_path)
  File "/usr/lib64/python3.6/site-packages/spacy/language.py", line 638, in from_disk
    util.from_disk(path, deserializers, exclude)
  File "/usr/lib64/python3.6/site-packages/spacy/util.py", line 522, in from_disk
    reader(path / key)
  File "/usr/lib64/python3.6/site-packages/spacy/language.py", line 625, in <lambda>
    ('vocab', lambda p: self.vocab.from_disk(p)),
  File "vocab.pyx", line 383, in spacy.vocab.Vocab.from_disk
  File "vectors.pyx", line 372, in spacy.vectors.Vectors.from_disk
  File "/usr/lib64/python3.6/site-packages/spacy/util.py", line 522, in from_disk
    reader(path / key)
  File "vectors.pyx", line 350, in spacy.vectors.Vectors.from_disk.load_key2row
  File "vectors.pyx", line 351, in spacy.vectors.Vectors.from_disk.load_key2row
  File "/usr/lib/python3.6/site-packages/msgpack_numpy.py", line 179, in unpack
    return _unpacker.unpack(stream, encoding=encoding, **kwargs)
AttributeError: module 'msgpack._unpacker' has no attribute 'unpack'

3 个答案:

答案 0 :(得分:3)

msgpack刚刚碰到v0.5.5~8小时前。

Commit da902f9中,unpack函数已从 msgpack / _unpacker.pyx 移至msgpack init文件。此更改已在最新版本中发布。

安装msgpack-python v0.5.4现在应该修复它。

答案 1 :(得分:1)

现在应该解决问题:pip install -U spacy。

答案 2 :(得分:0)

确保您没有其他名为“ spacy”的python文件。 hange文件名(如果可用)