. Advertisement .
..3..
. Advertisement .
..4..
When you try to complete your task, you get this error: “OSError: [E050] Can’t find model ‘en_core_web_sm’. It doesn’t seem to be a shortcut link, a Python package or a valid path to a data directory in Python“.
This error is one of the most popular errors any programmer will make. So, why does it appear, and how can it be resolved? We’ll go over it with you.
Why Does The Error: OSError: [E050] Can’t find model ‘en_core_web_sm’. It doesn’t seem to be a shortcut link, a Python package or a valid path to a data directory in Python Occur?
You are attempting to load en_core_web_sm and install spacy,
when going to jupyter notebook & run this code nlp = spacy.load('en_core_web_sm'),
but getting this error.
OSError: [E050] Can't find model 'en_core_web_sm'. It doesn't seem to be a shortcut link, a Python package or a valid path to a data directory.
The Effective Methods For You
Explanation for error
When you download spacy
spaCy attempts to locate the most suitable tiny model that is compatible with the distribution of your spaCy. The small model I am referring to is the default model, the web_sm en_core
which is available in various variations, which correspond to the various spaCy versions (for instance the spacy
, spacy-nightly
are all based on the en_core_web_sm
with different sizes).
If spaCy is able to find the most suitable model for you it downloads it, and connects its name the name
to the model the model downloaded e.g. en_core_web_sm
. This basically means that every time you use the term the word "en,"
you are talking about the en_core_web_sm
. That is, en
after linking isn’t an actual “real” package, it is simply a term used to describe the en_core_web_sm
.
It isn’t possible to directly refer to the en_core_web_sm
because your system does not realize that it is installed. If you performed a the spacy download
you basically performed the pip install. This means that pip knows you have a package titled en
that is installed in your python distribution, but is unaware concerning the package named en_core_web_sm
. The package is simply replacing the package en
by importing it, meaning that the package named en
is nothing more than an indirect link to the en_core_web_sm
.
And, guess what, we just solved it using one method we mentioned below.
Solution 1: Spacy.load like this way.
First, copy the entire path to en_core_web_sm. In our case, the path is C: “C:\Users\ssc\AppData\Local\Continuum\anaconda3\Lib\site-packages\en_core_web_sm\en_core_web_sm-2.2.0”
Then there’s spacy. Load in this manner.
nlp = spacy.load(r'C:\Users\ssc\AppData\Local\Continuum\anaconda3\Lib\site-packages\en_core_web_sm\en_core_web_sm-2.2.0')
Solution 2: Download the packages
You only need to use this command to download these packages.
python -m spacy download en_core_web_lg
python -m spacy download en_core_web_sm
Then you can execute this command.
python -m spacy download en
We believe that the above method will be beneficial to all of you.
Solution 3: Use this code
This code worked for us.
import en_core_web_sm
nlp = en_core_web_sm.load()
We believe that the above method will be beneficial to all of you.
Conclusion
The solutions mentioned above are the best options for those still confused with this error: “OSError: [E050] Can’t find model ‘en_core_web_sm’. It doesn’t seem to be a shortcut link, a Python package or a valid path to a data directory in Python”.
If you need our support or have other questions, we have a thriving community where everyone is always willing to help. Finally, we wish you a productive day filled with new solutions and code.
Leave a comment