spacy model in cloud function not working

Viewed 1514

my requirements.txt

spacy

my cloud function code:

import spacy
nlp = spacy.load("en_core_web_sm")

the error:

Function failed on loading user code. Error message: [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.

2 Answers

Your requirements.txt should look like this. The https link will directly download the spacy model and install it when you install the dependencies from requirements.txt. The spaCy models are valid python packages. Check this link for more details.

spacy
https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.2.0/en_core_web_sm-2.2.0.tar.gz#egg=en_core_web_sm
Related