我正面临" '模块'对象没有属性' util' "在python 2.7什么时候spacy.load(' en')
spacy详情:
Python version:** 2.7.9
Platform:** Linux-3.19.0-15-generic-x86_64-with-Ubuntu-15.04-vivid
spaCy version:** 2.0.0a9
Models:** en, en_core_web_sm
错误日志:
导入spacy
spacy.load('恩&#39)
追踪(最近一次呼叫最后一次):
文件"",第1行,
文件" /usr/local/lib/python2.7/dist-packages/spacy/ init .py",第13行,加载
return util.load_model(name, **overrides)
文件" /usr/local/lib/python2.7/dist-packages/spacy/util.py",第103行,在load_model中 return load_model_from_link(name,** overrides)
文件" /usr/local/lib/python2.7/dist-packages/spacy/util.py",第116行,在load_model_from_link中
spec = importlib.util.spec_from_file_location(name, init_file)
AttributeError:' module'对象没有属性' util'
**
我也试试这个:
**
import spacy
from spacy.util import get_data_path
data_path = get_data_path()
print([p for p in data_path.iterdir()])
[PosixPath('/usr/local/lib/python2.7/dist-packages/spacy/data/__init__.py'), PosixPath('/usr/local/lib/python2.7/dist-packages/spacy/data/en'), PosixPath('/usr/local/lib/python2.7/dist-packages/spacy/data/en_core_web_sm')]
print([p for p in data_path.iterdir() if p.is_dir()])
[PosixPath('/usr/local/lib/python2.7/dist-packages/spacy/data/en'), PosixPath('/usr/local/lib/python2.7/dist-packages/spacy/data/en_core_web_sm')]
print([p.parts[-1] for p in data_path.iterdir()])
['__init__.py', 'en', 'en_core_web_sm']
print([p.parts[-1] for p in data_path.iterdir() if p.is_dir()])
['en', 'en_core_web_sm']
答案 0 :(得分:0)
在我的情况下,我使用 Spacy 1.9 并且它正常工作
pip install spacy==1.9.0
python -m spacy download en