Search code examples
pythonnlpspacy

Spacy 2.0 Language Model load issues - from 'en_code_web_sm' to 'en_code_web_lg'


When I run the following code using en_code_web_sm

nlp = spacy.load("en_core_web_sm")
doc = nlp("Apple is looking at buying U.K. startup for $1 billion")
for token in doc:
    print(token.text, token.pos_, token.dep_)

but now when I change the language model to en_code_web_lg, I will have the following error:

OSError: [E050] Can't find model 'en_core_web_lg'. It doesn't seem to be a shortcut link, a Python package or a valid path to a data directory.
nlp = spacy.load("en_core_web_lg")
doc = nlp("Apple is looking at buying U.K. startup for $1 billion")
for token in doc:
    print(token.text, token.pos_, token.dep_)

Solution

  • Are you sure you downloaded the model 'en_core_web_lg' to disk?

    You can do this by running this in the command line:

    python -m spacy download en_core_web_lg
    

    or in the script:

    import spacy
    spacy.cli.download('en_core_web_lg')