10

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 :(

Adorable
  • 119
  • 1
  • 1
  • 6
  • 2
    Could you please provide more information? Have you downloaded the model `python -m spacy download en_core_web_sm`? – krisograbek Feb 25 '21 at 13:17

2 Answers2

16

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.

Ray Johns
  • 768
  • 6
  • 14
1

Just give this command. Change the version accordingly.

pip install https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.5.0/en_core_web_sm-3.5.0.tar.gz