I am looking to upgrade to the Individual plan and was hoping to port my NLP code into Anvil. I use SpaCy too, so will I experience this issue as well (referring to the issue posted [here])(Server error when loading Spacy lib)
Right now I use uplink to call SpaCy related functions. It’s not bad in terms of speed. Will I be better off using Uplink? My NLP code sits in my local machine, so its not ideal to depend on uplink.
You could activate your free trial of the Full Python 3 runtime and try it out. It will also depend on what SpaCy model you are trying to load into memory. In that other post you reference, they were loading the largest model, which requires a fair bit more memory than the medium and small models.
So I have now upgraded and moved to the full Python version in anvil.
In my server module, I have:
import spacy
```
but when I try to load the model:
```python
@anvil.server.callable
def loadSpacyModel():
nlp = spacy.load("en_core_web_sm")
print('Loaded SpaCy')
```
I get the following error:
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. at /usr/local/lib/python3.7/site-packages/spacy/util.py, line 119
called from /usr/local/lib/python3.7/site-packages/spacy/__init__.py, line 21 called from [ServerModule1, line 39](javascript:void(0)) called from [mockTest_template, line 16](javascript:void(0))
Not sure what I am missing. In my local machine, after installing spacy, this code was enough to load the model and work off it. Given it is already installed in Anvil's environment, I don't need to download and install again?
With some googling around, it seems the solution lies in downloading the model again.
For eg. in this post.
But I’m not sure where I’m supposed to do it…
Is somebody able to respond to this please? I am unable to make any progress if I do not have SpaCy working in my app. I was hoping that by upgrading, I will not have to depend on Uplink for the NLP aspects, however I have not any luck so far.
After a little digging myself, I think you are correct that the model needs to be downloaded separately as is implied in the Spacy docs. I will poke the relevant person to download this for you during the (UK) workday tomorrow. Hopefully the Uplink will suffice until then!
I had a couple users report that they are experiencing an error when they try using a feature in the app that uses SpaCy. Please refer to the conversation above.
I tried it now and indeed I get this error:
FileNotFoundError: [Errno 2] No such file or directory: ‘/usr/local/lib/python3.7/site-packages/spacy/data/en_core_web_sm/init.py’ at , line 916 called from , line 859 called from , line 724 called from /usr/local/lib/python3.7/site-packages/spacy/compat.py, line 135 called from /usr/local/lib/python3.7/site-packages/spacy/util.py, line 126 called from /usr/local/lib/python3.7/site-packages/spacy/util.py, line 112 called from /usr/local/lib/python3.7/site-packages/spacy/init.py, line 21 called from [ServerModule1, line 265](javascript:void(0)) called from [mockTest_template, line 35](javascript:void(0))
The error is at this line:
nlp = spacy.load(“en_core_web_sm”)
The last time this code was successfully accessed was around noon UK time, dec 15th.
I have not changed anything related to this feature since this version of the app got published. Any ideas please?
You could wait for someone who knows better to answer but…
Have you heard about the new ability to install packages? You might want to try installing the newest version of SpaCy directly into your anvil server and see if that works?