简体   繁体   中英

Can't load the spaCy 'en' module

So I'm trying to get space to work but it's giving me this error:

OSError: [E050] Can't find model 'en'. It doesn't seem to be a shortcut link, a Python package or a valid path to a data directory.

I have tried installing the module through the console, like 'python -m spacy download en' and a lot of other variations I found online to no success. I also tried to change spacy.load('en') to spacy.load('en_core_web_sm').

You may need to attempt installation in both the correct path and as an admin as stated in this post:

Spacy link error

You have to run python -m spacy download en_core_web_sm before you can use nlp = spacy.load("en_core_web_sm") .

en is a special case - it's a symbolic link. If you ran python -m spacy download en , what was the output? Was the symbol link created correctly?

More info here: https://spacy.io/usage/models

After you download the 'en' or 'en_core_web_sm' or any model,

You may validate your spaCy's version and installed model using this command:

python -m spacy validate

Then if you want to change the shortcut link to the model, you can use this command:

python -m spacy link [package name or path] [shortcut] [--force]

So for example in your case:

python -m spacy link en en_default

Or for 'en_core_web_sm':

python -m spacy link en_core_web_sm en_default

Then to load, just use:

spacy.load("en_default")

Check out spaCy's shortcut link

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM