加载spacy模型时出错AttributeError:module'msgpack._unpacker'没有属性'unpack'
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了加载spacy模型时出错AttributeError:module'msgpack._unpacker'没有属性'unpack'相关的知识,希望对你有一定的参考价值。
我在为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'
答案
msgpack刚刚碰到v0.5.5~8小时前。
在Commit da902f9中,unpack
函数从msgpack / _unpacker.pyx移动到msgpack init文件。此更改是在最新版本中。
安装msgpack-python v0.5.4现在应该修复它。
另一答案
现在应该解决问题:pip install -U spacy。
以上是关于加载spacy模型时出错AttributeError:module'msgpack._unpacker'没有属性'unpack'的主要内容,如果未能解决你的问题,请参考以下文章
使用 Spacy 使用 PySpark 和 Jupyter 解析文本时出错