问题
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