Mazze
Mazze

Reputation: 453

Why does using the full path solved the can't find model 'en_core_web_sm'

When I try to load en_core_web_sm from spacy with:

import spacy

nlp = spacy.load('en_core_web_sm')get the following error:

the following error occurs:

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

I used the installation instructions from spacy.io:

pip3 install -U pip setuptools wheel
pip3 install -U spacy
python3 -m spacy download en_core_web_sm

I solve this error, when using /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/en_core_web_sm/en_core_web_sm-3.2.0.

Can someone explain to me, why I have to get the full path to spacy.load?

Upvotes: 0

Views: 481

Answers (1)

EliasK93
EliasK93

Reputation: 3174

First download it in the console:

python -m spacy download en_core_web_sm

Then in the code you can use it:

import spacy
nlp = spacy.load("en_core_web_sm")

Check out the documentation.

Edit:

Since you downloaded the model already and it works when you provide the full path this might be a bug/issue with SpaCy not knowing where the already downloaded model is. I used to have similar problems e.g. when switching between conda environments (downloading the model in the default/system wide environment but running the code in a different environment).

Upvotes: 1

Related Questions