首页 文章

spaCy加载失败:'module'对象没有在RASA中使用的属性'util'

提问于
浏览
-1

我在python 2.7中面对“'module'对象没有属性'util'”什么时候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

错误日志:

import spacy spacy.load('en')

Traceback(最近一次调用最后一次):

文件“”,第1行,in

文件“/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中返回load_model_from_link(名称,**覆盖)

在load_model_from_link中的文件“/usr/local/lib/python2.7/dist-packages/spacy/util.py”,第116行

spec = importlib.util.spec_from_file_location(name, init_file)

AttributeError:'module'对象没有属性'util'

**

Also I try this:

**

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']

1 回答

  • 0

    在我的情况下,我使用 Spacy 1.9 并且它正常工作

    pip install spacy==1.9.0
    
    python -m spacy download en
    

相关问题