Can't find model 'en'. It looks like you're trying to load a model from a shortcut, which is obsolete as of spaCy v3.0

Viewed 377

I was trying to run

text_field = Field(tokenize='spacy', lower=True, include_lengths=True, batch_first=True)

However, the error shows :

OSError                                   Traceback (most recent call last)
<ipython-input-72-1ac550316aec> in <module>
      2 
      3 label_field = Field(sequential=False, use_vocab=False, batch_first=True, dtype=torch.float)
----> 4 text_field = Field(tokenize='spacy', lower=True, include_lengths=True, batch_first=True)
      5 fields = [('label', label_field), ('title', text_field), ('text', text_field), ('titletext', text_field)]
      6 

~/opt/anaconda3/lib/python3.8/site-packages/torchtext/data/field.py in __init__(self, sequential, use_vocab, init_token, eos_token, fix_length, dtype, preprocessing, postprocessing, lower, tokenize, tokenizer_language, include_lengths, batch_first, pad_token, unk_token, pad_first, truncate_first, stop_words, is_target)
    161         # in case the tokenizer isn't picklable (e.g. spacy)
    162         self.tokenizer_args = (tokenize, tokenizer_language)
--> 163         self.tokenize = get_tokenizer(tokenize, tokenizer_language)
    164         self.include_lengths = include_lengths
    165         self.batch_first = batch_first

~/opt/anaconda3/lib/python3.8/site-packages/torchtext/data/utils.py in get_tokenizer(tokenizer, language)
    112         try:
    113             import spacy
--> 114             spacy = spacy.load(language)
    115             return partial(_spacy_tokenize, spacy=spacy)
    116         except ImportError:

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

~/opt/anaconda3/lib/python3.8/site-packages/spacy/util.py in load_model(name, vocab, disable, exclude, config)
    424         return load_model_from_path(name, **kwargs)  # type: ignore[arg-type]
    425     if name in OLD_MODEL_SHORTCUTS:
--> 426         raise IOError(Errors.E941.format(name=name, full=OLD_MODEL_SHORTCUTS[name]))  # type: ignore[index]
    427     raise IOError(Errors.E050.format(name=name))
    428 

OSError: [E941] Can't find model 'en'. It looks like you're trying to load a model from a shortcut, which is obsolete as of spaCy v3.0. To load the model, use its full name instead:

nlp = spacy.load("en_core_web_sm")

For more details on the available models, see the models directory: https://spacy.io/models. If you want to create a blank model, use spacy.blank: nlp = spacy.blank("en")

I even tried to do python -m spacy download en but still doesn't run on my jupyter notebook. Does anyone know how to fix this problem?

0 Answers
Related