Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I know this question has been asked a couple of times but no matter how many solutions I've tried to run I still get the same error. This is the error I get:

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-248-fdd700a1da8b> in <module>
      8 STOPLIST = set(list(text.ENGLISH_STOP_WORDS))
      9 KEEP_POS = {'ADJ', 'ADP', 'ADV', 'NOUN', 'VERB'}
---> 10 nlp = spacy.load('en_core_web_sm')
     11 
     12 def scrubbing_text(reviews):

~/opt/anaconda3/lib/python3.8/site-packages/spacy/__init__.py in load(name, disable, exclude, config)
     45     RETURNS (Language): The loaded nlp object.
     46     """
---> 47     return util.load_model(name, disable=disable, exclude=exclude, config=config)
     48 
     49 

~/opt/anaconda3/lib/python3.8/site-packages/spacy/util.py in load_model(name, vocab, disable, exclude, config)
    327     if name in OLD_MODEL_SHORTCUTS:
    328         raise IOError(Errors.E941.format(name=name, full=OLD_MODEL_SHORTCUTS[name]))
--> 329     raise IOError(Errors.E050.format(name=name))
    330 
    331 

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'm using Anaconda on a mac. I can see the spaCy folder on the lefthand side but for some reason it won't work. Please help :(

like image 872
Adorable Avatar asked Dec 23 '22 15:12

Adorable


1 Answers

If you're using anaconda, you need to activate your conda environment before downloading the en_core_web_sm model.

  1. If you don't have an anaconda environment, first run conda create -n $envName, replacing $envName with whatever name you want.

  2. Activate your environment with conda activate $envName (again, replace the variable with whatever you put in step 1.

  3. Then install spacy with conda install spacy.

  4. Finally, run python -m spacy download en_core_web_sm.

Now, when you import spacy and try to load the model, it should work.

like image 133
Ray Johns Avatar answered Mar 08 '23 23:03

Ray Johns