ImportError [E048] Can't import language en from spacy.lang

ぃ、小莉子 提交于 2020-01-24 12:54:45

问题


I am trying to run 'en' for Spacy library, which took a lot of debugging to install and finally got it to import in the python library. Next step to load 'en', I spent lot of time debugging why I can't load the files and unable to load in any type of scenarios.

# in Python: These libraries are getting loaded. 
import spacy 
import ujson
import en_core_web_sm

In Command Line/ linux: I used command below to download 'en' for spacy.

python -m spacy download en

I got this successful message

"You can now load the model via spacy.load('en')."

Then I tried to run this and got this error in Python.

nlp = spacy.load('en')

doc = nlp(u'This is a sentence.')

Error: ImportError: [E048] Can't import language en from spacy.lang.

What I have tried?:

1) Download the jar file insert into this path: spacy.util.get_data_path()

2) Loading the files like this spacy.load('C:/path_to/Anaconda3/lib/site-packages/spacy/data/en') including jar file name passed in the spaces.

3) Running java -jar en_core_web_sm-2.0.0a7.tar and java -jar en-1.1.0.tar before running the script. It fails.

Any idea how to solve this? Greatly appreciated!


回答1:


I had the same error, try using

python -m spacy download en_core_web_sm

instead of

python -m spacy download en

In fact, the 'en' package is just a shortcut for the statistical model 'en_core_web_sm'.



来源:https://stackoverflow.com/questions/53676542/importerror-e048-cant-import-language-en-from-spacy-lang

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!